Characters are the basic symbols that are used to write or print a language. For example, the characters used by the English language consist of the letters of the alphabet, numerals, punctuation marks and a variety of symbols (e.g., the ampersand, the dollar sign and the arithmetic symbols). Printable characters are those which actually display on a monitor screen, as opposed to those that perform other functions, such as indicating a new line or a tab. A string is any finite sequence of characters, and it can be as few as one character.
The basic syntax of the strings command is
When used without any options, strings displays all strings that are at least four characters in length in the files whose names are supplied as arguments (i.e., input data). Strings that are on separate lines in the input files are shown on separate lines on the screen, and an attempt is made to display all strings found on a single line in a file on a single line on the screen (although there may be a carryover to subsequent lines in the event that numerous strings are found on a single line).
Perhaps the most commonly used of strings's few options is -n, which, when followed by an integer, tells it to return strings which are at least the number of that integer in length. For example, the following would display all strings in the files named file1 and file2 that consist of at least two characters:
The -t option tells strings to also return the offset position for each line on which one or more strings are found. This option is followed by a letter indicating the numbering system to be used, i.e., o for octal, d for decimal and x for hexadecimal. Each printing character, each space and the start of each new line add one to the count. Thus, for example, for a file named file3 which contains the string abcd followed by a single space and then by the string efghi on the first line and the string jklm on the second line, the following command would return the number 0 before the strings in the first line and the number 11 before the string in the second line:
The -f option tells strings to begin each line of its output with the name of the file from which it is returning a particular string, followed by a colon and then by several spaces. This can be useful when simultaneously searching for strings in multiple files.
Created January 26, 2006.