blob: 17e06761596bd0d32cae0537a0e01079098b5584 [file] [log] [blame]
<html lang="en">
<head>
<title>strings - GNU Binary Utilities</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Binary Utilities">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="size.html#size" title="size">
<link rel="next" href="strip.html#strip" title="strip">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1991-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="strings"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="strip.html#strip">strip</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="size.html#size">size</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">7 strings</h2>
<p><a name="index-strings-128"></a><a name="index-listings-strings-129"></a><a name="index-printing-strings-130"></a><a name="index-strings_002c-printing-131"></a>
<!-- man title strings print the sequences of printable characters in files -->
<pre class="smallexample"> <!-- man begin SYNOPSIS strings -->
strings [<samp><span class="option">-afovV</span></samp>] [<samp><span class="option">-</span></samp><var>min-len</var>]
[<samp><span class="option">-n</span></samp> <var>min-len</var>] [<samp><span class="option">--bytes=</span></samp><var>min-len</var>]
[<samp><span class="option">-t</span></samp> <var>radix</var>] [<samp><span class="option">--radix=</span></samp><var>radix</var>]
[<samp><span class="option">-e</span></samp> <var>encoding</var>] [<samp><span class="option">--encoding=</span></samp><var>encoding</var>]
[<samp><span class="option">-</span></samp>] [<samp><span class="option">--all</span></samp>] [<samp><span class="option">--print-file-name</span></samp>]
[<samp><span class="option">-T</span></samp> <var>bfdname</var>] [<samp><span class="option">--target=</span></samp><var>bfdname</var>]
[<samp><span class="option">-w</span></samp>] [<samp><span class="option">--include-all-whitespace</span></samp>]
[<samp><span class="option">-s</span></samp>] [<samp><span class="option">--output-separator</span></samp><var>sep_string</var>]
[<samp><span class="option">--help</span></samp>] [<samp><span class="option">--version</span></samp>] <var>file</var>...
<!-- man end -->
</pre>
<!-- man begin DESCRIPTION strings -->
<p>For each <var>file</var> given, <span class="sc">gnu</span> <samp><span class="command">strings</span></samp> prints the
printable character sequences that are at least 4 characters long (or
the number given with the options below) and are followed by an
unprintable character.
<p>Depending upon how the strings program was configured it will default
to either displaying all the printable sequences that it can find in
each file, or only those sequences that are in loadable, initialized
data sections. If the file type in unrecognizable, or if strings is
reading from stdin then it will always display all of the printable
sequences that it can find.
<p>For backwards compatibility any file that occurs after a command-line
option of just <samp><span class="option">-</span></samp> will also be scanned in full, regardless of
the presence of any <samp><span class="option">-d</span></samp> option.
<p><samp><span class="command">strings</span></samp> is mainly useful for determining the contents of
non-text files.
<!-- man end -->
<!-- man begin OPTIONS strings -->
<dl>
<dt><samp><span class="env">-a</span></samp><dt><samp><span class="env">--all</span></samp><dt><samp><span class="env">-</span></samp><dd>Scan the whole file, regardless of what sections it contains or
whether those sections are loaded or initialized. Normally this is
the default behaviour, but strings can be configured so that the
<samp><span class="option">-d</span></samp> is the default instead.
<p>The <samp><span class="option">-</span></samp> option is position dependent and forces strings to
perform full scans of any file that is mentioned after the <samp><span class="option">-</span></samp>
on the command line, even if the <samp><span class="option">-d</span></samp> option has been
specified.
<br><dt><samp><span class="env">-d</span></samp><dt><samp><span class="env">--data</span></samp><dd>Only print strings from initialized, loaded data sections in the
file. This may reduce the amount of garbage in the output, but it
also exposes the strings program to any security flaws that may be
present in the BFD library used to scan and load sections. Strings
can be configured so that this option is the default behaviour. In
such cases the <samp><span class="option">-a</span></samp> option can be used to avoid using the BFD
library and instead just print all of the strings found in the file.
<br><dt><samp><span class="env">-f</span></samp><dt><samp><span class="env">--print-file-name</span></samp><dd>Print the name of the file before each string.
<br><dt><samp><span class="env">--help</span></samp><dd>Print a summary of the program usage on the standard output and exit.
<br><dt><samp><span class="env">-</span><var>min-len</var></samp><dt><samp><span class="env">-n </span><var>min-len</var></samp><dt><samp><span class="env">--bytes=</span><var>min-len</var></samp><dd>Print sequences of characters that are at least <var>min-len</var> characters
long, instead of the default 4.
<br><dt><samp><span class="env">-o</span></samp><dd>Like &lsquo;<samp><span class="samp">-t o</span></samp>&rsquo;. Some other versions of <samp><span class="command">strings</span></samp> have <samp><span class="option">-o</span></samp>
act like &lsquo;<samp><span class="samp">-t d</span></samp>&rsquo; instead. Since we can not be compatible with both
ways, we simply chose one.
<br><dt><samp><span class="env">-t </span><var>radix</var></samp><dt><samp><span class="env">--radix=</span><var>radix</var></samp><dd>Print the offset within the file before each string. The single
character argument specifies the radix of the offset&mdash;&lsquo;<samp><span class="samp">o</span></samp>&rsquo; for
octal, &lsquo;<samp><span class="samp">x</span></samp>&rsquo; for hexadecimal, or &lsquo;<samp><span class="samp">d</span></samp>&rsquo; for decimal.
<br><dt><samp><span class="env">-e </span><var>encoding</var></samp><dt><samp><span class="env">--encoding=</span><var>encoding</var></samp><dd>Select the character encoding of the strings that are to be found.
Possible values for <var>encoding</var> are: &lsquo;<samp><span class="samp">s</span></samp>&rsquo; = single-7-bit-byte
characters (ASCII, ISO 8859, etc., default), &lsquo;<samp><span class="samp">S</span></samp>&rsquo; =
single-8-bit-byte characters, &lsquo;<samp><span class="samp">b</span></samp>&rsquo; = 16-bit bigendian, &lsquo;<samp><span class="samp">l</span></samp>&rsquo; =
16-bit littleendian, &lsquo;<samp><span class="samp">B</span></samp>&rsquo; = 32-bit bigendian, &lsquo;<samp><span class="samp">L</span></samp>&rsquo; = 32-bit
littleendian. Useful for finding wide character strings. (&lsquo;<samp><span class="samp">l</span></samp>&rsquo;
and &lsquo;<samp><span class="samp">b</span></samp>&rsquo; apply to, for example, Unicode UTF-16/UCS-2 encodings).
<br><dt><samp><span class="env">-T </span><var>bfdname</var></samp><dt><samp><span class="env">--target=</span><var>bfdname</var></samp><dd><a name="index-object-code-format-132"></a>Specify an object code format other than your system's default format.
See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
<br><dt><samp><span class="env">-v</span></samp><dt><samp><span class="env">-V</span></samp><dt><samp><span class="env">--version</span></samp><dd>Print the program version number on the standard output and exit.
<br><dt><samp><span class="env">-w</span></samp><dt><samp><span class="env">--include-all-whitespace</span></samp><dd>By default tab and space characters are included in the strings that
are displayed, but other whitespace characters, such a newlines and
carriage returns, are not. The <samp><span class="option">-w</span></samp> option changes this so
that all whitespace characters are considered to be part of a string.
<br><dt><samp><span class="env">-s</span></samp><dt><samp><span class="env">--output-separator</span></samp><dd>By default, output strings are delimited by a new-line. This option
allows you to supply any string to be used as the output record
separator. Useful with &ndash;include-all-whitespace where strings
may contain new-lines internally.
</dl>
<!-- man end -->
</body></html>