Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

strings - find printable strings in files

&pagelevel(4)&pagelevel

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...]

-a

strings searches the entire file for printable strings.

This corresponds to the old option -, which is still supported.

-a not specified:
strings only looks in the initialized data space of object files. 

-n number

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:
A string is any sequence of 4 or more printable characters ending with a newline character or a null byte.

-o

strings precedes each string by its offset in the file.

-t format

Each string is output preceded by its offset in the file. The format of the positioning specification is defined as follows:

dDecimal positioning specification
oOctal positioning specification
xHexadecimal positioning specification

file

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:

$ strings a.out
L
LLM-UFS
~                       2020-07-16198 15:33:24
...
Hello, user
...

C(BS2000) COMPILER: V04.0A06,COMPILATION DATE: 2020-07-16,REP AREA:
...

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