STRINGS(1POSIX)

๐Ÿ’– STRINGS(1POSIX) ๐Ÿ’–

okay bestie, welcome to the POSIX Programmer's Manual page for strings, from the IEEE/The Open Group era, no cap. this one's short and sweet and honestly kinda iconic.


๐ŸŒธ PROLOG ๐ŸŒธ

okay so first things first, this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ, so like... consult the corresponding Linux manual page for details on Linux behavior, mmkay? or the interface might just not be implemented on Linux at all. it's giving "read the fine print bestie". ๐Ÿ’…


โœจ NAME โœจ

strings โ€” find printable strings in files ๐Ÿฆ‹


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

strings [-a] [-t format] [-n number] [file...]

๐Ÿ’ซ DESCRIPTION ๐Ÿ’ซ

so the strings utility shall look for printable strings in regular files and shall write those strings to standard output. periodt. ๐Ÿ’…

a printable string is any sequence of four (by default) or more printable characters, terminated by a <newline> or NUL character. four characters minimum by default, bestie, remember that.

additional implementation-defined strings may be written; see localedef for the tea on that. ๐Ÿ“

ok but WARNING: if the first argument is -, the results are unspecified. unspecified means it's the wild west, bestie, do NOT count on it. ๐Ÿ˜ญ

๐ŸŒˆ OPTIONS ๐ŸŒˆ

the strings utility shall conform to the Base Definitions volume of POSIX.1โ€2017, Section 12.2, Utility Syntax Guidelines, except for the unspecified usage of -. (yes the same - from before. it stays messy. ๐Ÿ™ˆ)

the following options shall be supported:

  • -a โ€” scan files in their entirety. and if -a is not specified? then it's implementation-defined what portion of each file is scanned for strings. so like, lowkey mysterious behavior. ๐Ÿ‘‘
  • -n number โ€” specify the minimum string length, where the number argument is a positive decimal integer. the default shall be 4. โœจ
  • -t format โ€” write each string preceded by its byte offset from the start of the file. the format shall be dependent on the single character used as the format option-argument:
    • d โ€” the offset shall be written in decimal.
    • o โ€” the offset shall be written in octal.
    • x โ€” the offset shall be written in hexadecimal.

๐Ÿซถ OPERANDS ๐Ÿซถ

the following operand shall be supported:

  • file โ€” a pathname of a regular file to be used as input. and if no file operand is specified, the strings utility shall read from the standard input. no file? stdin it is, bestie. ๐Ÿ’œ

โญ STDIN โญ

see the INPUT FILES section. (it's right below. keep scrolling. i gotchu. ๐ŸŽ€)


๐ŸŒธ INPUT FILES ๐ŸŒธ

the input files named by the utility arguments or the standard input shall be regular files of any format. any format!! it does not care. main character energy. ๐Ÿ‘‘


๐Ÿงš ENVIRONMENT VARIABLES ๐Ÿงš

the following environment variables shall affect the execution of strings:

  • LANG โ€” provide a default value for the internationalization variables that are unset or null. (see the Base Definitions volume of POSIX.1โ€2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) ๐ŸŒ
  • LC_ALL โ€” if set to a non-empty string value, override the values of all the other internationalization variables. it overrides EVERYTHING. the boss. ๐Ÿ’…
  • LC_CTYPE โ€” determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files) and to identify printable strings. ๐Ÿ”ค
  • 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. ๐Ÿ—‚๏ธ

๐Ÿ’€ ASYNCHRONOUS EVENTS ๐Ÿ’€

default. that's it. that's the whole section. moving on. ๐Ÿฆ‹


โœจ STDOUT โœจ

strings found shall be written to the standard output, one per line. ๐ŸŒˆ

when the -t option is not specified, the format of the output shall be:

"%s", <string>

with the -t o option, the format of the output shall be:

"%o %s", <byte offset>, <string>

with the -t x option, the format of the output shall be:

"%x %s", <byte offset>, <string>

with the -t d option, the format of the output shall be:

"%d %s", <byte offset>, <string>

look at all those formats, bestie. slay. ๐Ÿ’…


๐ŸŽ€ STDERR ๐ŸŽ€

the standard error shall be used only for diagnostic messages. that's it. no drama there. ๐Ÿ™ˆ


๐Ÿฆ‹ OUTPUT FILES ๐Ÿฆ‹

none. nothing. zero. the void. ๐Ÿ’€


๐Ÿ’œ EXTENDED DESCRIPTION ๐Ÿ’œ

none. same energy. โญ


๐ŸŒŸ EXIT STATUS ๐ŸŒŸ

the following exit values shall be returned:

  • 0 โ€” successful completion. ๐ŸŽ‰
  • >0 โ€” an error occurred. ๐Ÿ˜ญ

๐Ÿ“ CONSEQUENCES OF ERRORS ๐Ÿ“

default.

the following sections are informative. (iykyk โ€” informative means it's the lore, not the rules. ๐Ÿ“–โœจ)


๐ŸŒˆ APPLICATION USAGE ๐ŸŒˆ

by default the data area (as opposed to the text, ``bss'', or header areas) of a binary executable file is scanned. implementations document which areas are scanned. ๐Ÿ‘€

some historical implementations do not require NUL or <newline> terminators for strings, to permit those languages that do not use NUL as a string terminator to have their strings written. history lesson, bestie. ๐Ÿงš


๐Ÿ’… EXAMPLES ๐Ÿ’…

none. ๐Ÿ˜ญ i know. tragic. no examples for us today.


๐Ÿ‘‘ RATIONALE ๐Ÿ‘‘

apart from rationalizing the option syntax and slight difficulties with object and executable binary files, strings is specified to match historical practice closely. the -a and -n options were introduced to replace the non-conforming - and -number options. these options are no longer specified by POSIX.1โ€2008 but may be present in some implementations. โš ๏ธ

the -o option historically means different things on different implementations. some use it to mean offset in decimal'', while others use it as offset in octal''. instead of trying to decide which way would be least objectionable, the -t option was added. it was originally named -O to mean ``offset'', but was changed to -t to be consistent with od. character development honestly. ๐Ÿ’œ

the ISO C standard function is isprint(), and it's restricted to a domain of unsigned char. this volume of POSIX.1โ€2017 requires implementations to write strings as defined by the current locale. ๐ŸŒ


๐Ÿ”ฎ FUTURE DIRECTIONS ๐Ÿ”ฎ

none. the future is... nothing? for this page at least. ๐Ÿ’€


๐ŸŒธ SEE ALSO ๐ŸŒธ

  • localedef
  • nm

the Base Definitions volume of POSIX.1โ€2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines


portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html . ๐Ÿซถ

any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . ๐Ÿ›


okay that's the whole page bestie, you made it to the end, iconic behavior honestly ๐ŸŒˆโœจ. this one came to you from IEEE/The Open Group, dated 2017, and it's the STRINGS(1POSIX) page. go forth and find your printable strings, my love. ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹๐ŸŒธ๐Ÿ’…๐Ÿซถ

๐Ÿ“ฆ where this page comes from