Up to main menu         Back to File names and Wildcard symbols         Next: Dot Files

Other Basic Commands

The Unix philosophy is to have lots of little programs, each of which does a specific job very well. These units can be strung together in very useful ways, but for now, here are some more of the basic commands.

more filename
Display the contents of the text file, one screenful at a time (use Spacebar to advance screen). If the file is not plain text, you'll just see a bunch of garbage.

head filename
Display only the first 10 lines of the file. To see the first 17 lines instead, use the command with an extra parameter;
head -17 filename

tail filename
Display the final 10 lines of the file...

wc filename
(word count) Counts the words, lines, and characters in the file.

cat filename1 filename2 filename3 ...
(concatenate) List the contents of the named files, one after the other, onto the screen.

cat filename1 filename2 filename3 > newfile
Concatenate the list of files into one long new file.

cat filename1 filename2 filename3 >> existingfile
Concatenate the list of files onto the end of an existing file.

grep string filename(s)
Display each line of the named file(s) which contain the given string; e.g.
grep faul README
grep -i smith file1 file2
The first example displays all the lines in file README which contain the string ``faul''. The second example lists all the lines of either file1 or file2 which contain ``smith'' or ``Smith'' or ``SMITH''; the -i option informs grep to ignore case.

man command
Display the manual page for the given command. This is how you learn to use a Unix command correctly, and how to use the possible options which give the command more power.

man -k keyword
Sometimes you don't know what commands exist in Unix. Using the -k option you can get a list of commmands which pertain to a given keyword. For example,
man -k editor
gives you a list of all the Unix commands whose brief descriptions contain the key word "editor". If the resulting list is too long, try pruning and displaying it one screenful at a time;
man -k edit | sort -u | more

date
Show the current date and time

clear
clear the text window

cal
Show a calendar of this month. For a calendar of an entire year, append the year;
cal 1997

file filename(s)
Indicate the type of each file, i.e., whether it is a text file, a directory, binary data, compiled executable, shell script, etc.

Up to main menu         Back to File names and Wildcard symbols         Next: Dot Files
Bruce.Fast@Colorado.EDU