strings
is a
shell command that extracts
printable character
In ISO/IEC 646 (commonly known as ASCII) and related standards including ISO 8859 and Unicode, a graphic character, also known as printing character (or printable character), is any character intended to be written, printed, or otherwise display ...
strings from a
file which is particular useful for analyzing the content of a
binary file
A binary file is a computer file that is not a text file. The term "binary file" is often used as a term meaning "non-text file". Many binary file formats contain parts that can be interpreted as text; for example, some computer document files ...
. By definition, a binary file contains data that is not printable text yet a binary file often does contain some printable character text often in relatively short sequences distributed throughout the file. These portions of the binary file can be informative as to what the file contains overall. For a
text file
A text file (sometimes spelled textfile; an old alternative name is flat file) is a kind of computer file that is structured as a sequence of lines of electronic text. A text file exists stored as data within a computer file system.
In ope ...
, a file containing all printable characters, the command prints the entire file content, and therefore, provides no utility over more commonly used file output commands such as
cat
The cat (''Felis catus''), also referred to as the domestic cat or house cat, is a small domesticated carnivorous mammal. It is the only domesticated species of the family Felidae. Advances in archaeology and genetics have shown that the ...
.
The command searches for sequences of printable characters that end with a
NUL character but ignores any sequence that is less than a specified length or 4 characters by default. Some implementations provide options for determining what is recognized as a printable character, which is useful for finding non-
ASCII
ASCII ( ), an acronym for American Standard Code for Information Interchange, is a character encoding standard for representing a particular set of 95 (English language focused) printable character, printable and 33 control character, control c ...
and
wide character text. By default, it only selects strings from the initialized and loaded sections of an object file. For other types of files, it selects strings from the whole file.
The command is available in
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
,
Plan 9,
Inferno, and
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
systems. It is part of the
GNU Binary Utilities (), and has been implemented in other operating systems including
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
.
cygwin
Cygwin ( ) is a free and open-source Unix-like environment and command-line interface (CLI) for Microsoft Windows. The project also provides a software repository containing open-source packages. Cygwin allows source code for Unix-like operati ...
Example
The following command searches the system's
BIOS
In computing, BIOS (, ; Basic Input/Output System, also known as the System BIOS, ROM BIOS, BIOS ROM or PC BIOS) is a type of firmware used to provide runtime services for operating systems and programs and to perform hardware initialization d ...
for strings that are at 8 characters long:
dd if=/dev/mem bs=1k skip=768 count=256 2>
/dev/null
In some operating systems, the null device is a device file that discards all data written to it but reports that the write operation succeeded. This device is called /dev/null on Unix and Unix-like systems, NUL: (see TOPS-20) or NUL on CP/M a ...
, strings -n 8
See also
*
*
*
*
References
External links
*
*
*
Unix text processing utilities
Unix SUS2008 utilities
Plan 9 commands
Inferno (operating system) commands
String (computer science)
{{unix-stub