Skip to content

Instantly share code, notes, and snippets.

@BenSYZ
Created April 26, 2021 02:53
Show Gist options
  • Save BenSYZ/a643b3ce05d65cfe8e6437f38bf59ae5 to your computer and use it in GitHub Desktop.
Save BenSYZ/a643b3ce05d65cfe8e6437f38bf59ae5 to your computer and use it in GitHub Desktop.
awk grep except the first line
#!/bin/sh
var="$*"
lsof -i|awk -v pattern="$var" '
NR==1 {print $0};
NR>=1 && $0 ~ pattern {print $0}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment