Skip to content

Instantly share code, notes, and snippets.

@slntopp
Created January 28, 2022 12:53
Show Gist options
  • Save slntopp/19350b57cf3ff28d2fa8a5bbf9bce266 to your computer and use it in GitHub Desktop.
Save slntopp/19350b57cf3ff28d2fa8a5bbf9bce266 to your computer and use it in GitHub Desktop.
Some well-known bash tricks I tend to forget sometimes

Files Manipulation

Editing

Filter file for unique lines

awk '!a[$0]++' file

Searching

Show 2 lines before and 1 after in grep

echo "" | grep -B 2 -A 1 "pattern"

Extract by pattern (mac) in grep

echo "" | grep -Eo "regex"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment