Examining Files Flashcards
The “file” command displays a..?
file’s type.
The “cat” command displays a…?
file’s contents.
The “more” and “less” commands “page” through….?
a file, one screen at a time.
The “head” and “tail” commands display…?
the first or last few lines of a file.
In the X graphical environment, “nautilus” can be used to…?
examine text files.
The contents of any given file might be…?
ASCII (plain text, HTML, shell script, program source code, etc.) or binary (complied executable, compressed archive, audio, etc.).
It is a good idea to check the file type before using commands that work on ASCII because…?
Attempting to use them with binary files can lead to problems ranging from the mildly irritating (screens full of strange characters flashing by) to the more significant (locking the terminal display). This is because binary files can contain arbitrary binary codes, and some of these codes have special meaning when being (mis)interpreted as ASCII text.
file [OPTIONS][FILE….]…?
Tests FILE(s) to determine the file type, and displays results to standard output.
cat [OPTIONS] [FILE…]…?
Concatenate FILE(s) to standard output.
cat command switches…?
Switch Effect
- A Show all characters, including control characters and non-printing characters
- s “ Squeeze” multiple adjacent blank lines into a single blank line
- n Number lines of output
the cat command, when used for viewing files, simply displays…?
the contents all at once (Large files scroll by to quickly to read, making cat most suitable for files with less than a screen of text.)
Both more and less are designed for viewing text files on screen. Their use is quite similar except that…?
the modern less command has a few extra features, such as responding correctly to [PgUp], [PgDn] and navigation arrow keystrokes correctly. After all, less is more. (It is especially important to be familiar with less because other tools (such as man) use it behind the scenes to provide paging capabilities.)
more [OPTIONS] [FILE…] …?
Displays FILE(s) to standard output one screen full at a time under keyboard control.
“more” command switches…?
Option Action
- c Clear screen and redraw, instead of scrolling
- s “Squeeze” multiple adjacent blank lines into a single blank line
less [OPTIONS] [FILE…] …?
Displays FILE(s) to standard output one screen full at a time under keyboard control.