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

Author: Abhilash

Hey! This is Abhilash - A Ruby developer for years, specialised on web development, working as a freelance Ruby Developer. I have experience in other frameworks such as Angular, Sinatra, Laravel etc. Mainly working on Ruby On Rails platform since 2010. This blog is about Ruby, Ruby On Rails and other subjects where I have had a chance to work on. You can contact me here: abhilash.amballur@gmail.com Abhilash AK

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 )

Google photo

You are commenting using your Google 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