Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Last active November 27, 2021 22:52
Show Gist options
  • Save thingsiplay/fe6925209de0ef0c082a68a41025deef to your computer and use it in GitHub Desktop.
Save thingsiplay/fe6925209de0ef0c082a68a41025deef to your computer and use it in GitHub Desktop.
nogrep - Search matching lines with sed and print their non matching part of the lines.
#!/bin/sh
# Search matching lines with sed and print their non matching part of the lines.
# Usage:
# nogrep filter [sed_options]
# Examples:
# nogrep 'output' changelog.txt
# ls | nogrep '\(J\).*$' -E
filter=$1
shift 1
sed -n "/$filter/s/$filter//p" $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment