next up previous contents index
Next: Information Commands Up: Powerful Little Programs Previous: System Statistics

What's in the File?

There are two major commands used in Unix for listing files, cat and more. I've talked about both of them in Chapter gif.

cat  [-nA] [file1 file2 ...fileN]

cat is not a user friendly command--it doesn't wait for you to read the file, and is mostly used in conjuction with pipes. However, cat does have some useful command-line options. For instance, n will number all the lines in the file, and A will show control characters as normal characters instead of (possibly) doing strange things to your screen. (Remember, to see some of the stranger and perhaps ``less useful'' options, use the man command: man cat.) cat will accept input from stdin if no files are specified on the command-line.

more  [-l] [+linenumber] [file1 file2 ...fileN]

more is much more useful, and is the command that you'll want to use when browsing ASCII text files. The only interesting option is l, which will tell more that you aren't interested in treating the character tex2html_wrap8312 as a ``new page'' character. more will start on a specified linenumber.

Since more is an interactive command, I've summarized the major interactive commands below:

tex2html_wrap8314
Moves to the next screen of text.
tex2html_wrap8316
This will scroll the screen by 11 lines, or about half a normal, 25-line, screen.
tex2html_wrap8318
Searches for a regular expression. While a regular expression can be quite complicated, you can just type in a text string to search for. For example, /toad tex2html_wrap8258 would search for the next occurence of ``toad'' in your current file. A slash followed by a return will search for the next occurence of what you last searched for.
tex2html_wrap8322
This will also search for the next occurence of your regular expression.
tex2html_wrap8324 tex2html_wrap8322
If you specified more than one file on the command line, this will move to the next file.
tex2html_wrap8324 tex2html_wrap8330
This will move the the previous file.
tex2html_wrap8274
Exits from more.

head  [-lines] [file1 file2 ...fileN]

head will display the first ten lines in the listed files, or the first ten lines of stdin if no files are specified on the command line. Any numeric option will be taken as the number of lines to print, so head -15 frog will print the first fifteen lines of the file frog.

tail  [-lines] [file1 file2 ...fileN]

Like head, tail will display only a fraction of the file. Naturally, tail will display the end of the file, or the last ten lines that come through stdin. tail also accepts a option specifying the number of lines.

file [file1 file2 ...fileN]

The file command attempts to identify what format a particular file is written in. Since not all files have extentions or other easy to identify marks, the file command performs some rudimentary checks to try and figure out exactly what it contains.

Be careful, though, because it is quite possible for file to make a wrong identification.


next up previous contents index
Next: Information Commands Up: Powerful Little Programs Previous: System Statistics

Converted on:
Mon Apr 1 08:59:56 EST 1996