Viewing File Contents
You can use several commands for looking inside files without having to pull out a text editor utility (see Chapter 10). This section demonstrates a few of the commands you have available to help you examine files.
Viewing the file type
Before you go charging off trying to display a file, try to get a handle on what type of file it is. If you try to display a binary file, you get lots of gibberish on your monitor and may even lock up your terminal emulator.
The file
command is a handy little utility to have around. It can peek inside of a file and determine just what kind of file it is:
$ file my_file
my_file: ASCII text
$
The file in the preceding example is a text
file. The file
command determined not only that the file contains text but also the character code format of the text file, ASCII
.
This following example shows a file that is simply a directory. Thus, the file
command gives you another method to distinguish a directory:
$ file New_Dir
New_Dir: directory...