Programming in UNIX Environment : Commands – echo, rm, whoami

Take a look to the following UNIX commands.
who am i -This command shows your user name,teletype,date and time.

whoami – Shows only user name.

In UNIX systems,

parent directory is denoted by ‘..’
current directory is denoted by ‘.’

rmdir – for remove a directory. It removes only empty directories.

About shell :

When we type the commands it goes to the shell.It is an ordinary program.

cat c* //prints all file that begins with c.

when * occurs shell takes it and it means any string of characters. Note the * is not the property of the cat command.

The echo command lists what we type.

echo word

echo ch* //lists all begin wth ch.

echo * //lists all.

rm * – removes all.

rm *.text – removes all with .text.

pr r[1234]* // prints all that begin wth r and followed by 1,2,3 or 4.

rm te[a-z] //removes all files starting with te and followed by a lower case.

You cannot make up new files using pattern matching.

ls \? or ls ‘?’ loses its meaning.

echo * // prints all.

We can redirect the output by using ‘>’. Take input from a file by using ‘>’.

ls > filelist

pr -3 <filelist // print ls in three columns.

cat file1.c file2.c > file3

cat file4.c >> file3.c

grep num.c <filelist

Advertisement

Author: Abhilash

I'm Abhilash, a web developer who specializes in Ruby development. With years of experience working with various frameworks like Rails, Angular, Sinatra, Laravel, NodeJS, React and more, I am passionate about building robust and scalable web applications. Since 2010, I have been honing my skills and expertise in the Ruby on Rails platform. This blog is dedicated to sharing my knowledge and experience on topics related to Ruby, Ruby on Rails, and other subjects that I have worked with throughout my career. Join me on this journey to explore the exciting world of web development!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: