tools:grep
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:grep [2024/06/03 08:21] – Humphrey Boa-Gart | tools:grep [2024/09/28 03:07] (current) – Humphrey Boa-Gart | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{wst> | ||
- | |||
====== grep ====== | ====== grep ====== | ||
- | **grep** is a command line text search utility originally written for Unix. The name is taken from the first letters in global | + | **grep** is a command line text search utility originally written for Unix. The name is taken from a command for the ancient UNIX text editor **ed** - '' |
+ | |||
+ | If you are using a modern version of Linux, chances are that '' | ||
+ | |||
+ | |||
+ | ===== Useful Commands ===== | ||
+ | |||
+ | Using '' | ||
+ | |||
+ | ==== Built-in Documentation ==== | ||
+ | |||
+ | '' | ||
+ | |||
+ | |||
+ | ==== Search For Lines in Files ==== | ||
+ | |||
+ | To search within // | ||
+ | |||
+ | $ grep -n " | ||
+ | |||
+ | ==== Search Files in Current Directory ==== | ||
+ | |||
+ | You can also use '' | ||
+ | |||
+ | $ grep “INSERTSTRING” * | ||
+ | |||
+ | You can also use the // | ||
+ | |||
+ | $ grep “INSERT*” * | ||
+ | |||
+ | Or to search for all //.txt// files containing //INSERT*// it would be: | ||
+ | |||
+ | $ grep “INSERT*” *.txt | ||
+ | |||
+ | The '' | ||
+ | |||
+ | $ grep -R " | ||
+ | |||
+ | You can combine flags as well. To search your pwd and all child directories recursively for all //.txt// files containing // | ||
+ | |||
+ | $ grep -Rn " | ||
+ | |||
+ | |||
+ | ==== Search Files in Specific Directories ==== | ||
+ | |||
+ | To search a specific directory path for all files containing // | ||
+ | |||
+ | $ grep " | ||
+ | |||
+ | The aforementioned flags work on specific directories as well: | ||
+ | |||
+ | $ grep -Rn " | ||
- | ===== Download ===== | + | ==== More Command Flags ==== |
- | [[http:// | + | There are more flags you can combine with these basic '' |
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
===== Variations ===== | ===== Variations ===== | ||
- | There are countless implementations and derivatives of grep available for many operating systems, as well as for aiding searches in third-party applications such as EnCase (computer forensic software). Early variants of grep included | + | There are countless implementations and derivatives of '' |
**pcregrep** is an implementation of grep that uses Perl regular expression syntax. | **pcregrep** is an implementation of grep that uses Perl regular expression syntax. | ||
- | Other commands contain the word ' | + | Other commands contain the word ''grep'' to indicate that they search |
- | In [[tools: | + | In [[tools: |
- | The DOS, OS/2 and Windows platforms provide the find command for simple string searches. Windows also provides the "findstr" | + | The DOS, OS/2 and Windows platforms provide the '' |
===== External Links ===== | ===== External Links ===== | ||
- | [[http:// | + | [[https:// |
{{tag> | {{tag> |
tools/grep.1717402899.txt.gz · Last modified: 2024/08/06 05:52 (external edit)
Find this page online at: https://bestpoint.institute/tools/grep
Find this page online at: https://bestpoint.institute/tools/grep