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/09/28 02:42] – [Search Files in Current Directory] Humphrey Boa-Gart | tools:grep [2025/09/30 22:44] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== grep ====== | ====== grep ====== | ||
| - | **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** - '' | + | **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 grep is already installed on your system. If not, it is probably in your distro' | + | If you are using a modern version of Linux, chances are that '' |
| ===== Useful Commands ===== | ===== Useful Commands ===== | ||
| - | Using grep may seem obtuse to new users at first. However, once you know how to structure your commands, it is the absolute fastest way to do many common searches: | + | Using '' |
| + | |||
| + | ==== Built-in Documentation ==== | ||
| + | |||
| + | '' | ||
| Line 19: | Line 23: | ||
| ==== Search Files in Current Directory ==== | ==== Search Files in Current Directory ==== | ||
| - | You can also use grep to search inside all the files within a folder, and not just one. Just replace the filename with an asterisk. To search the PWD for all files containing // | + | You can also use '' |
| $ grep “INSERTSTRING” * | $ grep “INSERTSTRING” * | ||
| Line 27: | Line 31: | ||
| $ grep “INSERT*” * | $ grep “INSERT*” * | ||
| - | The '' | + | Or to search for all //.txt// files containing //INSERT*// it would be: |
| + | |||
| + | $ grep “INSERT*” *.txt | ||
| + | |||
| + | The '' | ||
| $ grep -R " | $ grep -R " | ||
| - | You can combine flags as well. To search your PWD and all child directories recursively for all files containing // | + | You can combine flags as well. To search your pwd and all child directories recursively for all // |
| - | $ grep -Rn " | + | $ grep -Rn " |
| Line 42: | Line 50: | ||
| $ grep " | $ grep " | ||
| - | '' | + | The aforementioned flags work on specific directories as well: |
| + | |||
| + | $ grep -Rn " | ||
| - | $ grep -R " | + | ==== More Command Flags ==== |
| + | 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 ===== | ||
tools/grep.1727491340.txt.gz · Last modified: (external edit)
Find this page online at: https://bestpoint.institute/tools/grep
Find this page online at: https://bestpoint.institute/tools/grep