Jump to content

strings (Unix)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Stevebroshar (talk | contribs) at 08:28, 2 May 2025 (add short desc). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
strings
Written inC
Operating systemUnix, Unix-like, Plan 9, Inferno
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License

strings is a shell command that searches a file for printable character strings and writes them to standard output.

The command can be useful for analyzing the information in a binary file. 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 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 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 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, Plan 9, Inferno, and Unix-like operating systems. It is part of the GNU Binary Utilities (binutils), and has been implemented to other operating systems including Windows.[1]

Example

Using strings to print sequences of characters that are at least 8 characters long (this command prints the system's BIOS information; should be run as root):

dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8 | less

See also

References