Next: Text files and editors:
Up: Introduction to the Linux
Previous: Full-stops, Wildcards and Tab-Completion
In Linux files that are human readable are often referred to as
text files, and files that are machine readable are referred to
as binary files. All programs are binary files and so programs
are often referred to as binaries.
If you want to look at the contents of a text file there are several
commands you might want to use.
- cat
Short for `concatenate' this command writes a file or files to the
terminal window.
- head
Writes the first few ten lines of the file to the terminal window. You
can use head -24 to write the first 24 lines, or use any
number you like.
- tail
This is like head but writes the last few lines of a file to
a terminal. A particularly useful switch is `-f' which writes
the end of the file and then waits for any changes to the file and
writes those as they are written. To quit, hold down the control key
and press X (more about the control key later).
- more and less
The more command, and the slightly more advanced
less, let you look at a file interactively. The display the
first window full of text from the file, and then you can press the
spacebar to scroll down by one page or the b key to scroll
back up one page. You can also search for text by typing `/' followed
by the text you wish to search for, and then pressing the enter
key. To go to the next occurence of the text press `n' and `b' will
take you back to the previous occurence. The less command
will also let you move through the file using the arrow keys. Press
`q' to quit.
- grep
This is an extremely useful command which is used to search a file or
files for a particular text string or pattern. We will return to this
command later.
One common task we use computers for is to create or edit text
files. There are many text editors available under Linux, but probably
the most common are vi, emacs and
pico.
Please note that these are text editors, not word
processors or typesetting programs - they don't have any founts or
different sizes of text, and the output will not look pretty. However
they are quick to load, reasonably quick to run over a network, and
will not insert any nasty command characters into your document.
Next: Text files and editors:
Up: Introduction to the Linux
Previous: Full-stops, Wildcards and Tab-Completion
Phil Hasnip
2007-08-23