next up previous contents
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 [Ctrl-L] 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:

[Spacebar]
Moves to the next screen of text.
[d]
This will scroll the screen by 11 lines, or about half a normal, 25-line, screen.
[/]
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[Enter] would search for the next occurrence of ``toad'' in your current file. A slash followed by a return will search for the next occurrence of what you last searched for.
[n]
This will also search for the next occurrence of your regular expression.
[:][n]
If you specified more than one file on the command line, this will move to the next file.
[:][p]
This will move the the previous file.
[q]
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 an 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
Next: Information Commands Up: Powerful Little Programs Previous: System Statistics



Ross Biro
Thu May 25 10:45:54 PDT 1995