more
A very useful program for viewing files. More not only shows a file one
screen at a time (spacebar to advance one screen, Enter to advance one line)
but it also recognizes many of the commands of the vi editor, including
searching, scrolling, and others.
more test.html
less
less is like more, but allows scrolling backwards, and will gracefully
handle binary files, among other useful features.
cat
cat is extremely useful, and simple, yet it can be very frustrating to
inexperienced UNIX users. The reason for this is that by just typing
'cat' at a prompt, the user will have all text typed in merely repeated
on the next line. cat takes input from a given place (default is keyboard)
and outputs it to another place (default is monitor). When used with
UNIX plumbing (described later) it becomes very useful.
cat testfile takes testfile as input and outputs to monitor
cat can be exited normally with ^D, or interrupted with ^C.
grep
The word 'grep' is actually a macro from one of the first text editors
in the UNIX world. This oft-used macro was "Get Regular Expression Print"
which looked like 'g/re/p' in the editor. This command is extremely useful
in searching files for a given word or phrase.
grep dmtc * shows all lines of all files with 'dmtc' appearing
grep -l dmtc * shows which files contain pattern 'dmtc'
touch
Will change the time/date stamp on a file, which indicates the last time
the file was modified, to the present moment. If no file exists, it
will create an empty file by that name.
vi
This editor is the Visual form of the old 'ed' line editor. While
powerful and sophisticted, its commands are awkward (designed to allow
all cursor movement, etc. from a standard US keyboard) and it can be very
hard to master (as randomly pressing keys will merely produce beeping).
In vi, there are three basic modes: escape mode, insert mode, and a command
mode. All editor commands, such as moving the cursor, or deleting text,
is done in the escape mode (which is reached by pressing the Esc key).
Text can be inserted using the 'a' or 'i' keys while in escape mode
(for 'add' and 'insert' respectively) which will place it into insert
mode, and all text becomes part of the document.
File mode is reached by pressing ':' while in escape mode. A ':' will
appear at the bottom of the window, and there commands can be entered
such as 'q!' or 'wq' for "quit" or "write and quit" respectively.
The cursor is moved with the h, j, k, and l keys. h and l move left and
right while j and k move up and down.
As a simple lesson in vi, try this:
vi test
When you enter the editor, try this:
i (goes into insert mode)
this is a test (text is being entered)
[Esc] (escape key, go into escape mode)
: (command mode, colon appears at bottom of screen)
wq (write to disk and quit)
Note that if you are in escape mode and you press escape, the program
will beep after a short delay to let you know this. It is generally
safe to press escape a few times just to be sure.