cat - Concatenate or display files
Format
cat [-Bsu] [-v[et]] [-W option[,option]...] [file ... file ...]
Description
cat displays and concatenates files. It copies each file argument to the standard output (stdout). If you specify no files or specify a dash (-) as a file name, cat reads the standard input (stdin).
You can use cat with the scrolling facility of the z/OS® UNIX TSO/E command to browse data files.
Options
- -B
- Disables the automatic conversion of tagged files. This option is ignored if the filecodeset or pgmcodeset options (-W option) are specified.
- -e
- Displays a
$
character at the end of each line. This option works only if you also specify -v. - -s
- Does not produce an error message if cat cannot find or read a specified file.
- -t
- Displays tabs as
^I
. This option works only if you also specify -v. - -u
- Does not buffer output.
- -v
- Displays all characters including those that are unprintable characters. With a double-byte character set, an unprintable wide character
is converted back to its double-byte representation. Each byte is then checked as if it were a
single-byte character. If the character is unprintable, one of the following three representations
is used:
M-X
is used for characterX
if the significant bit is set.^X
is used for the control characterX
(for example,^A
for CTRL-A).- \
xxx
represents a character with the octal valuexxx
.
The \
xxx
form is used if neither of the other representations can be used. - -W option[,option]...
- Specifies z/OS-specific options. The option keywords are case-sensitive. Possible
options are:
- filecodeset=codeset
- Performs text conversion from one code set to another when reading from the file. The coded
character set of the file is codeset. codeset
can be a code set name that is known to the system or a numeric coded character set identifier
(CCSID). The command
iconv -l
lists existing CCSIDs along with their corresponding code set names. The filecodeset and pgmcodeset options can be used on files with any file tag.If pgmcodeset is specified but filecodeset is omitted, then the default file code set is ISO8859-1 even if the file is tagged with a different code set. If neither filecodeset nor pgmcodeset is specified, text conversion will not occur unless automatic conversion is enabled or the _TEXT_CONV environment variable indicates text conversion. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
If filecodeset or pgmcodeset is specified, then automatic conversion is disabled for this command invocation and the -B option is ignored if it is also specified. For more information about automatic conversion, see Converting files between code pages in z/OS UNIX System Services Planning.
When specifying values for filecodeset, use the values that Unicode Service supports.
- pgmcodeset=codeset
- Performs text conversion from one code set to another when reading from the file. The coded
character set of the program (command) is codeset.
codeset can be a code set name that is known to the system or a numeric
coded character set identifier (CCSID). Note that the command
iconv -l
lists existing CCSIDs along with their corresponding code set names. The filecodeset and pgmcodeset options can be used on files with any file tag.If filecodeset is specified but pgmcodeset is omitted, then the default program code set is IBM-1047. If neither filecodeset nor pgmcodeset is specified, text conversion will not occur unless automatic conversion is enabled or the _TEXT_CONV environment variable indicates text conversion. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
If filecodeset or pgmcodeset is specified, then automatic conversion is disabled for this command invocation and the -B option is ignored if it is also specified. For more information about automatic conversion, see Using Enhanced ASCII in z/OS UNIX System Services Planning.The only supported values for pgmcodeset are IBM-1047 and 1047.
Examples
- To display the contents of a text file to the standard output
(stdout):
cat myTextFile
- To display the concatenation of two text files to the standard
output (stdout):
cat myTextFile01 myTextFile02
- To display the contents of a text file containing UTF-8 characters to the standard output
(stdout), assuming that:
- The text file is untagged and you do not want to tag it or enable automatic conversion, and
- You cannot alter the tag (for example, you are displaying an untagged public text file or a read-only text file):
cat -W filecodeset=UTF-8,pgmcodeset=IBM-1047 myutf8File
- To display the contents of a text file that contains UTF-8 characters
to the standard output (stdout), assuming that automatic conversion
was enabled but the text file is incorrectly tagged as ASCII:
cat -W filecodeset=UTF-8,pgmcodeset=IBM-1047 myUtf8File
Localization
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- LC_SYNTAX
- NLSPATH
Environment variables
- _TEXT_CONV
- Contains text conversion information for the command. The text conversion information is not used when either the -B option or the filecodeset or pgmcodeset option (-W option) is specified. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
Exit values
0
- Successful completion
1
-
- The code set is not valid.
- Could not turn off automatic conversion.
- Could not perform requested text conversion.
- An incorrect command-line argument.
- Inability to open the input file.
- End of the file detected on stdout.
- The input file is the same as the output file.
2
- An incorrect command-line argument
Portability
POSIX.2, X/Open Portability Guide, UNIX systems
The -B, -e, -s, -t, -v, and -W options are extensions of the POSIX standard.
Related information
cp, more, mv