-->
Previous | Table of Contents | Next |
cat......Concatenate Files
cat option(s) files
PURPOSE
The cat command is the most useful command in the Linux operating system, thanks to the many (mostly) mundane functions that it performs. On a basic level, it reads a file and prints it to standard output (usually the screen, unless standard output has been piped to another command or file). The cat command can also be combined with the > operator to combine files into a single file, as well as the >> operator to append files to an existing file. Finally, the cat command can create a new text file when combined with the name of a new file.
OPTIONS
-A or --show-all | Prints nonprinting and control characters, except for linefeeds and tabs; places a dollar sign at the end of each line; and prints tabs as ^I. (The same as -vET.) |
-e, -E, or --show-ends | Prints a dollar sign ($) at the end of each line. |
-n | Numbers the lines, beginning with 1 at the beginning of the first line. |
-s | Squeezes out blank lines. |
-t | Prints each tab as ^I and form feeds as ^L. |
-T or --show-tabs | Prints each tab as ^I. |
-u | Doesnt do anything; exists for compatibility with other UNIX scripts. |
-v | Shows nonprinting and control characters, except for linefeeds and tabs. |
EXAMPLES
$ cat report
This displays the file named report.
$ cat report report2
This displays the file report, followed immediately by the file report2.
$ cat report report2 > report3
This combines report and report2 into a new file called report3. The combination occurs in the order that the files are specified on the command line.
$ cat report > report2
This copies the contents of the file report into a new file named report2. The old file report remains unchanged.
$ cat > report
This creates a new file named report and sends your subsequent keyboard input into the file. You can end the input by pressing Ctrl-D.
$ cat report >> report2
This places the contents of the file report at the end of the existing file report2.
$ cat - >> report
This places keyboard input at the end of the existing file report2. You can end the input by pressing Ctrl-D.
RELATED COMMANDS
cmp......Compare Files
cmp option(s) filename1 filename2
PURPOSE
The cmp command compares the contents of two files. If theres no difference between the files, theres no return from cmp. If the files are different, then cmp returns the line number and byte position of the first difference. This command can be used with binary files as well as text files, as opposed to text-only tools like diff.
OPTIONS
-c | Prints the differing bytes as characters. | |
-i num | Ignores the first num of bytes in the files. | |
-l | Displays the byte position and differing characters for all differences within the files. | |
-s | Works in silent mode, returning only the exit codes and not any instances of differences. The exit code is one of the following: | |
0 | Files are identical. | |
1 | Files are different. | |
2 | One of the files cannot be read. |
EXAMPLE
$ cmp report memo report memo differ: char 12, line 1
RELATED COMMANDS
colrm......Column Remove
colrm start stop file
PURPOSE
The colrm command removes columns from a specified file, but there must be only one character in a line, separated by spaces.
column......Column Formatting
column option(s) file
PURPOSE
The column command formats input into columns, whether from a file or from standard input.
OPTIONS
-c num | Sets the number of columns as num. |
-s char | Sets char as the column delimiter. Must be used in conjunction with -t. |
-t | Formats input as a table and not as a column. The default is to format with spaces, unless an alternative has been set with -s. |
-x | Fills characters before filling the rows. |
comm......Compare Files
comm option(s) file1 file2
PURPOSE
The comm command compares the contents of two files that have already been sorted with the sort command. The output is sorted into three columns:
Lines in file1 | Lines in file2 | Lines in both files |
This command is similar to the diff and uniq commands, except that comm can be used with two sorted files to seek out duplicate or unique lines.
OPTIONS
-1 | Suppresses the printing of the first column. |
-2 | Suppresses the printing of the second column. |
-3 | Suppresses the printing of the third column. |
-12 | Suppresses the printing of the first and second columns. |
-13 | Suppresses the printing of the first and third columns. |
-23 | Suppresses the printing of the second and third columns. |
RELATED COMMANDS
Previous | Table of Contents | Next |