Thursday, September 2, 2010

Programming in UNIX Environment : Commands - sort, tail, cmp, diff

The command 'sort' is for sorting the line of the text. 'tail' prints the last ten lines of the file. 'cmp' for showing the difference between the files. It shows only the first difference. But 'diff' shows all the difference between two files.

sort filename1 file2
sort -r // reverse normal order.
sort -n // numeric order.
sort -f // fold upper and lower case together.
sort -b // Ignore the leading blanks.

tail filename // prints last 10 lines.
tail -3 filename // print last 3 lines.

cmp filename1 filename2 // prints only the 1st difference.

diff filen1 filen2 // prints all differences.

pwd - For printing current working directory.
cp - For copying a file.

cp /home/abhi/Pclass/num.c num.c

ed /home/abhi/Pclass/num.c

No comments:

Post a Comment