CAT(1) | User Commands | CAT(1) |
cat - concatenate and display files
/usr/bin/cat [-nbsuvet] [file...]
cat [-bdenstuvABDEST] [file...]
The cat utility reads each file in sequence and writes it on the standard output. Thus:
example% cat file
prints file on your terminal, and:
example% cat file1 file2 >file3
concatenates file1 and file2, and writes the results in file3. If no input file is given, cat reads from the standard input file.
The cat built-in in ksh93 is associated with the /bin and /usr/bin paths. It is invoked when cat is executed without a pathname prefix and the pathname search finds a /bin/cat or /usr/bin/cat executable. cat copies each file in sequence to the standard output. If no file is specified, or if the file is -, cat copies from standard input starting at the current location.
The following options are supported by /usr/bin/cat:
-b
-n
-s
-u
Buffered output is the default.
-v
When used with the -v option, the following options can be used:
-e
-t
The -e and -t options are ignored if the -v option is not specified.
ksh93 cat supports the following options:
-b --number-nonblank
-d --dos-input
-e
-n --number
-s
-t
-u --unbuffer
-v --show-nonprinting
-A --show-all
-B --squeeze-blank
-D --dos-output
-E --show-ends
-S --silent
-T --show-blank
The following operand is supported:
file
See largefile(7) for the description of the behavior of cat when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
Example 1 Concatenating a File
The following command writes the contents of the file myfile to standard output:
example% cat myfile
Example 2 Concatenating Two files into One
The following command concatenates the files doc1 and doc2 and writes the result to doc.all.
example% cat doc1 doc2 > doc.all
Example 3 Concatenating Two Arbitrary Pieces of Input with a Single Invocation
When standard input is a terminal, the following command gets two arbitrary pieces of input from the terminal with a single invocation of cat:
example% cat start - middle - end > file
If standard input is a regular file,
example% cat start - middle - end > file
would be equivalent to the following command:
example% cat start - middle /dev/null end > file
because the entire contents of the file would be consumed by cat the first time − was used as a file operand and an end-of-file condition would be detected immediately when − was referenced the second time.
See environ(7) for descriptions of the following environment variables that affect the execution of cat: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned:
0
>0
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
CSI | Enabled |
Interface Stability | Committed |
Standard | See standards(7). |
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | See below. |
The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-in interfaces are Uncommitted.
touch(1), attributes(7), environ(7), largefile(7), standards(7)
Redirecting the output of cat onto one of the files being read causes the loss of the data originally in the file being read. For example,
example% cat filename1 filename2 > filename1
causes the original data in filename1 to be lost.
September 19, 2020 | OmniOS |