Skip to content

Instantly share code, notes, and snippets.

@murarisumit
Last active January 10, 2018 14:48
Show Gist options
  • Save murarisumit/38a63a11942edaa1bd8c93fb921585b8 to your computer and use it in GitHub Desktop.
Save murarisumit/38a63a11942edaa1bd8c93fb921585b8 to your computer and use it in GitHub Desktop.
Xargs command snippets
#list the file opened by process-id
ps aux | grep 'index.js' | grep -v 'grep' | awk '{ print $2 }' | xargs -I {} sh -c "lsof -p {}"
#list the file opened by process other than specified pid
ps aux | grep 'index.js' | grep -v 'grep' | awk '{ print $2 }' | xargs -I {} sh -c "lsof -p ^{}"
# list network services by process-id
ps aux | grep 'index.js' | grep -v 'grep' | awk '{ print $2 }' | xargs -I {} sh -c "lsof -i | grep {}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment