Tuesday, August 10, 2010

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 '<' followed by filename.When the file does not exist it will be created. For redirecting output to a file without losing the data of yhe file we uses '>>'.

ls > filelist

pr -3
cat file1.c file2.c > file3

cat file4.c >> file3.c

grep num.c

No comments:

Post a Comment