strings - Display printable strings in binary files
Format
strings [-aBoxz] [-n number] [-t format] [-W option[option] ... [file ... file ...]
strings [-] [-Boxz] [-t format] [-W option[option] ... [-number] [file ... file ...]
Description
If the command line specifies a file name of -, strings reads the standard input. strings finds pieces of information in binary files. It is frequently used for looking through executable files to uncover items such as copyright notices, error messages, and undocumented features.
The command displays strings of printable characters that are at least four characters in length. Strings must be terminated by a NUL character or by a newline.
Options
- -a
- This option has no effect in the z/OS environment. The entire file is examined, regardless of whether or not this option is specified.
- -B
- Disables the automatic conversion of tagged files. This option is ignored if the filecodeset or pgmcodeset options (-W option) are specified.
- -n number
- Displays strings of printable characters that are at least number characters in length. If you do not specify the -n option, strings acts as if -n 4 had been specified.
- -o
- For each string, displays as an octal value its offset in bytes from the beginning of the file. This option is the same as -t o.
- -t format
- For each string, displays its offset in bytes from the beginning of the file. The base of the offset is set to decimal, octal, or hexadecimal by specifying format as d, o, or x, respectively.
- -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). 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 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 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 Converting files between code pages in z/OS UNIX System Services Planning.
When specifying values for filecodeset, use the values that Unicode Service supports.
- -x
- For each string, displays as a hexadecimal value its offset in bytes from the beginning of the file. This option is the same as -t x.
- -z
- Ignores the POSIX definition of a string and searches for any group of printable characters greater than four in length.
- -
- Is the obsolete version of -a.
- -number
- Is the obsolete version of -n number.
Examples
- To display printable EBCDIC strings in a binary file to the standard output (stdout):
strings myBinaryFile
- To display printable ASCII strings in a binary file to the standard output (stdout):
strings -W filecodeset=ISO8859-1,pgmcodeset=IBM-1047 myBinaryFile
- To display printable EBCDIC strings in a binary file, assuming that automatic conversion has
been enabled but the binary file is incorrectly tagged as an UTF-8 text file:
strings -B myMisTaggedFile
Localization
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- 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
- Failure due to any of the following reasons:
- Incorrect command-line option.
- Insufficient memory.
- The code set is not valid.
- Could not turn off automatic conversion.
- Could not perform requested text conversion.
Portability
POSIX.2 User Portability Extension, X/Open Portability Guide.
A Berkeley addition to most UNIX systems. Most Berkeley versions do not require the terminating NUL or newline.
The -B, -o, -W, -x, and -z options are extensions of the POSIX standard.