Skip to content

Instantly share code, notes, and snippets.

@chriseaton
Created December 10, 2024 19:24
Show Gist options
  • Save chriseaton/e62f4185666830f91e6c2df0a800f2ea to your computer and use it in GitHub Desktop.
Save chriseaton/e62f4185666830f91e6c2df0a800f2ea to your computer and use it in GitHub Desktop.
# use grep to search the output of the file for specific terms.
# the `-n` flag will output line numbers to the left of matches.
cat some.log | grep -n "Looking for..."
# you can then use the line number to find the entries on and around the entry.
# Note the line-number is used, as well as a count to includes a number of lines after.
# In this example, we're looking at lines starting at 3176101 and the +10 lines after.
sed -n '3176101,+10p' app.log
# OTHER
# need a solid sed cheatsheet? Check this out: https://edoras.sdsu.edu/doc/sed-oneliners.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment