Tuesday, June 17, 2008

wc

Use this command to count the number of characters, words, and lines in a file. Suppose, for example, that we have a file dict with contents

red rojo
green verde
blue azul
white blanco
black negro
Then we can do this
   % wc dict
5 10 56 tmp

This shows that dict has 5 lines, 10 words, and 56 characters.

The word count command has several options, as illustrated below:

   % wc -l dict
5 tmp
% wc -w dict
10 tmp
% wc -c dict
56 tmp

telnet

Use this command to log in to another machine from the machine you are currently working on. For example, to log in to the machine "solitude", do this:

   % telnet solitude 

See also: rsh.

tar

Use create compressed archives of directories and files, and also to extract directories and files from an archive. Example:

   % tar -tvzf foo.tar.gz 

displays the file names in the compressed archive foo.tar.gz while

   % tar -xvzf foo.tar.gz 
extracts the files.

tail

Use this command to look at the tail of a file. For example,

   % tail essay.001 

displays the last 10 lines of the file essay.001 To see a specific number of lines, do this:

   % tail -n 20 essay.001 
This displays the last 20 lines of the file.

sort

Use this commmand to sort a file. For example, suppose we have a file dict with contents
red rojo
green verde
blue azul
white blanco
black negro
Then we can do this:
   % sort dict
black negro
blue azul
green verde
red rojo
white blanco
Here the output of sort went to the screen. To store the output in file we do this:
   % sort dict >dict.sorted  
You can check the contents of the file dict.sorted using car, more, or emacs.

setenv

   % echo $PRINTER
labprinter
% setenv PRINTER myprinter
% echo $PRINTER
myprinter

rsh

Use this command if you want to work on a computer different from the one you are currently working on. One reason to do this is that the remote machine might be faster. For example, the command

   % rsh solitude 

connects you to the machine solitude. This is one of our public workstations and is fairly fast.

See also: telnet