strings - find printable strings in files
strings [-a][-t format][-n number][file...] strings [-][-t format][-number][file...]
The strings utility looks for printable strings in regular files and writes those strings to standard output. A printable string is any sequence of four (by default) or more printable characters terminated by a newline or NUL character. Additional implementation-dependent strings may be written. (See localedef.)
The strings utility supports the XBD specification, Utility Syntax Guidelines except that the obsolescent version uses "-" in a non-standard way and allows a multi-digit option, -number.
The following options are supported:
- Scan files in their entirety. If -a is not specified, it is implementation-dependent what portion of each file is scanned for strings.
- -n number
- Specify the minimum string length, where the number argument is a positive decimal integer. The default is 4.
- -t format
- Write each string preceded by its byte offset from the start of the file. The format is dependent on the single character used as the format option-argument:
- The offset will be written in decimal.
- The offset will be written in octal.
- The offset will be written in hexadecimal.
The following operand is supported:
- A pathname of a regular file to be used as input. If no file operand is specified, the strings utility will read from the standard input.
See the INPUT FILES section.
The input files named by the utility arguments or the standard input must be regular files of any format.
The following environment variables affect the execution of strings:
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files) and to identify printable strings.
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Strings found are written to the standard output, one per line.
When the -t option is not specified, the format of the output is:
With the -t o option, the format of the output is:
"%o %s", <byte offset>, <string>
With the -t x option, the format of the output is:
"%x %s", <byte offset>, <string>
With the -t d option, the format of the output is:
"%d %s", <byte offset>, <string>
Used only for diagnostic messages.
The following exit values are returned:
- Successful completion.
- An error occurred.
By default the data area (as opposed to the text, "bss" or header areas) of a binary executable file is scanned. Implementations will document which areas are scanned.
Some historical implementations do not require NUL or newline character terminators for strings to permit those languages that do not use NUL as a string terminator to have their strings written.