grep
grep
- CLI utility for searching text data sets for matching expressions.
- You can use
\|to separate "OR" strings- For example,
grep '445\|CLOSED\|ESTABLISHED' firewalloutput.txt
- For example,
- Important options
-ior--ignore-case- Search for string, regardless of case
- Useful when adversaries use alternating caps to prevent search matches
-vor--invert-match- Searches for any results that do NOT include the search term
-nor--line-number- Get the line number with the output
-lor--files-with-matches- Just lists file names with matching content
- Windows alternatives
- In PowerShell:
Select-String - In Windows command line (cmd.exe),
findstr
- In PowerShell:
Simple file copy script using for
for file in $(grep -l "search_string" /files/to/sea.rch); do
cp "$file" /path/to/destination/
done