Thursday, August 5, 2010

Programming in UNIX environment : Commands - ed, cat, ls, pr,

In UNIX environment we use a lot of commands. Some commands are explaining here.
For editing a file we use ed command.
$ed file1
no such file or...
a
Enter the text
.
w file1
q
$

When we type the command 'ed' and the filename, if the file does not exist, it shows a message. Type 'a' for appending. After adding types a '.' character in the next line to indicate writing is over.Then write it into the file by typing 'w' and the file name.And 'q' to quit.
The command 'cat' shows the content of the file.
$cat sachin
$cat sachin num
'pr' instead shows the content by pages and the file name.In 'pr -m filename' the 'm' indicates the columns.
pr sachin
pr sachin num
$pr -3 sachin num
$pr -m // a set of files in parallel columns.

The 'ls' command lists all the files. The ls * lists all including the files in the directories.

ls DIRname
$ls *
$ls -t // list by time.
$ls -l //list by details.
$ls -lt //list by details by recent first.
$ls -u // infn abt when files were used.
$ls -ult // most recent.

No comments:

Post a Comment