Skip to content

Instantly share code, notes, and snippets.

@Kishan033
Created February 18, 2022 12:21
Show Gist options
  • Save Kishan033/290d4aa1cb4aa01449e7b5d783db3613 to your computer and use it in GitHub Desktop.
Save Kishan033/290d4aa1cb4aa01449e7b5d783db3613 to your computer and use it in GitHub Desktop.
To check large files with grep

grep commands

To check large files with grep

Get all matches

grep "match" filename.txt

Get count of matches

grep -c "match" filename.txt

Get all matches and save in file

grep "match" filename.txt > savelogs.log

Search from multiple files

grep "match" filename.txt filename2.txt > savelogs.log
OR
grep "match" std{err,debug}.log > savelogs.log

Search matcha and get next n lines

grep -A n "match" filename.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment