This option only works under the MS-DOS and Microsoft Windows platforms and needs to be invoked with -b. u, -unix-byte-offsets grep -u -b pattern filename For instance, it can separate line numbers, byte offsets, labels, etc., from the matching text. This option is useful for clarifying the layout. Inserts a tab before each matching line, putting the tab between the information generated by grep and the match- ing lines. T, -initial-tab grep -T pattern filename This can be useful in code debug- ging, allowing you to go into the file and specify a partic- ular line number to start editing. Includes the line number of each line displayed, where the first line of the file is 1. n, -line-number grep -n pattern filename In this example, the gzip command displays the contents of the uncompressed file inside file.gz and then passes that to When the input is taken from standard input (for instance, when the output of another file is redirected into grep), the –label option will prefix the line with LABEL. label=LABEL gzip -cd file.gz | grep -label=LABEL pattern This is useful for suppressing filenames when searching entire directories. It is the default when only one file or standard input is in- volved. When more than one file is involved, it suppresses printing the filename before each output. Note that this uses the relative (not absolute) paths and filenames. This is useful when searching only one file and you want the filename to be contained in the output. Includes the name of the file before each line printed, and is the default when more than one file is input to the search. H, -with-filename grep -H pattern filename This causes grep to print the byte offset of the start of the matched string instead of the matched line. grep -b -o pattern filenameĪ -o option prints the offset along with the matched pat- tern itself and not the whole matched line containing the pattern. This is particularly useful for binary file analysis, constructing (or reverse-engineering) patches, or other tasks where line numbers are meaningless. Because entire lines are printed by default, the number displayed is the byte offset of the start of the line. The first byte in the file is byte 0, and invisible line-terminating characters (the newline in Unix) are counted. Output Line Prefix Control -b, -byte-offset grep -b pattern filenameĭisplays the byte offset of each matching text instead of the line number.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |