strings — Display printable strings in binary files

Format

Start of changestrings [–aBoxz] [–n number] [–t format] [-W option[,option]...] [file …file …]End of change

Start of changestrings [] [–Boxz] [–t format] [-W option[,option]...] [number] [file …file …]End of change

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
Start of changeDisables the automatic conversion of tagged files. This option is ignored if the filecodeset or pgmcodeset options (-W option) are specified.End of change
–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.
Start of change-W option[,option]...End of change
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 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. See z/OS UNIX System Services Planning for more information about automatic conversion.

Start of changeWhen specifying values for filecodeset, use the values that Unicode Service supports. For more information about supported code sets, see z/OS Unicode Services User's Guide and Reference.End of change

Start of changepgmcodeset=codesetEnd of change
Start of changePerforms 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. See z/OS UNIX System Services Planning for more information about automatic conversion.

Start of changeWhen specifying values for filecodeset, use the values that Unicode Service supports. For more information about supported code sets, see z/OS Unicode Services User's Guide and Reference.End of change

End of change
–x
For each string, displays as a Start of changehexadecimalEnd of change 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.
Start of change

Examples

  1. To display printable EBCDIC strings in a binary file to the standard output (stdout):
    strings myBinaryFile
  2. To display printable ASCII strings in a binary file to the standard output (stdout):
    strings -W filecodeset=ISO8859-1,pgmcodeset=IBM-1047 myBinaryFile
  3. 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 Start of changeUTF-8End of change text file:
    strings -B myMisTaggedFile
End of change

Localization

strings uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Start of change

Environment variables

strings uses the following environment variable:
_TEXT_CONV
Contains text conversion information for the command. The text conversion information is not used when either the -B option Start of changeor the filecodeset or pgmcodeset option (-W option)End of change is specified. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
End of change

Exit values

0
Successful completion
1
Failure due to any of the following:
  • Incorrect command-line option
  • Insufficient memory
  • Start of changeThe code set is not validEnd of change
  • Start of changeCould not turn off automatic conversionEnd of change
  • Start of changeCould not perform requested text conversionEnd of change

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.

Start of changeThe –B, –o, –W, –x, and –z options are extensions of the POSIX standard.End of change