1.\" Copyright (c) 2007 S.Sam Arun Raj
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $Id: strings.1 3360 2016-01-24 18:34:06Z jkoshy $
26.\"
27.Dd January 24, 2016
28.Dt STRINGS 1
29.Os
30.Sh NAME
31.Nm strings
32.Nd "print the strings of printable characters in files"
33.Sh SYNOPSIS
34.Nm
35.Op Fl a | Fl -all
36.Op Fl e Ar encoding | Fl -encoding= Ns Ar encoding
37.Op Fl f | Fl -print-file-name
38.Op Fl h | Fl -help
39.Op Fl n Ar number | Fl -bytes= Ns Ar number | Fl Ar number
40.Op Fl o
41.Op Fl t Ar radix | Fl -radix= Ns Ar radix
42.Op Fl v | Fl -version
43.Op Ar
44.Sh DESCRIPTION
45For each
46.Ar file
47specified, the
48.Nm
49utility prints contiguous sequences of printable
50characters that are at least
51.Va n
52characters long and are followed by an unprintable character.
53The default value of
54.Va n
55is 4.
56By default, the
57.Nm
58utility only scans the initialized and loaded sections of ELF objects;
59for other file types, the entire file is scanned.
60The
61.Nm
62utility is mainly used for determining the contents of non-text files.
63.Pp
64If no file name is specified as an argument, standard input is read.
65.Pp
66The following options are available:
67.Bl -tag -width indent
68.It Fl a | Fl -all
69For ELF objects, scan the entire file for printable strings.
70.It Fl e Ar encoding | Fl -encoding= Ns Ar encoding
71Select the character encoding to be used while searching for strings.
72Valid values for argument
73.Ar encoding
74are:
75.Bl -tag -width indent -compact
76.It Ar s
77for single 7-bit-byte characters (ASCII, ISO 8859).
78.It Ar S
79for single 8-bit-byte characters.
80.It Ar l
81for 16-bit little-endian.
82.It Ar b
83for 16-bit big-endian.
84.It Ar L
85for 32-bit little-endian.
86.It Ar B
87for 32-bit big-endian.
88.El
89The default is to assume that characters are encoded using a single
907-bit byte.
91.It Fl f | Fl -print-file-name
92Print the name of the file before each string.
93.It Fl h | Fl -help
94Print a usage summary and exit.
95.It Xo
96.Fl n Ar number |
97.Fl -bytes= Ns Ar number |
98.Fl Ar number
99.Xc
100Print the contiguous character sequence of at least
101.Ar number
102characters long, instead of the default of 4 characters.
103Argument
104.Ar number
105should specify a positive decimal integer.
106.It Fl o
107Equivalent to specifying
108.Fl t Ar o .
109.It Fl t Ar radix | Fl -radix= Ns Ar radix
110Print the offset from the start of the file before each string
111using the specified radix.
112Valid values for argument
113.Ar radix
114are:
115.Bl -tag -width indent -compact
116.It Ar d
117for decimal
118.It Ar o
119for octal
120.It Ar x
121for hexadecimal
122.El
123.It Fl v | Fl -version
124Display a version identifier and exit.
125.El
126.Sh EXIT STATUS
127.Ex -std
128.Sh EXAMPLES
129To display strings in
130.Pa /bin/ls
131use:
132.Dl "$ strings /bin/ls"
133.Pp
134To display strings in all sections of
135.Pa /bin/ln
136use:
137.Dl "$ strings -a /bin/ln"
138.Pp
139To display strings in all sections of
140.Pa /bin/cat
141prefixed with the filename and the offset within the file use:
142.Dl "$ strings -a -f -t x /bin/cat"
143.Sh SEE ALSO
144.Xr ar 1 ,
145.Xr nm 1 ,
146.Xr objdump 1 ,
147.Xr ranlib ,
148.Xr readelf 1 ,
149.Xr size 1
150.Sh HISTORY
151The first FreeBSD
152.Nm
153utility appeared in
154.Fx v3.
155It was later discontinued in
156.Fx v5 ,
157when i386-only a.out format was dropped in favor of ELF.
158.Sh AUTHORS
159.An -nosplit
160The
161.Nm
162utility was re-written by
163.An S.Sam Arun Raj Aq Mt samarunraj@gmail.com .
164This manual page was written by
165.An S.Sam Arun Raj Aq Mt samarunraj@gmail.com .
166