strings looks for strings in binary files and writes them on standard output. A string is by default any sequence of 4 or more printable ASCII characters ending with a newline or a null byte (see section “ASCII character set (ISO 646)”). strings is useful for identifying random object files and many other things.
Syntax
Format 1: |
strings[ -a][ -o][ -t format][ -n number][ file...] |
Format 2: |
strings[ -][ -o][ -t format][ -number][ file...] |
strings searches the entire file for printable strings. This corresponds to the old option -, which is still supported. -a not specified:
Defines a strings as any sequence of number or more printable characters ending with a newline or a null byte. This corresponds to the old option -number, which is still supported. -n not specified:
strings precedes each string by its offset in the file.
Each string is output preceded by its offset in the file. The format of the positioning specification is defined as follows:
Name of the file in which strings is to look for printable strings. |
Locale
The following environment variables affect the execution of strings: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE 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), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example
Finding all printable strings in the executable binary file a.out:
This could be the output for a file that originally held the following source code: #include <stdio.h> main() { printf("Hello, user\n"); } |
See also
nm, od |