Skip to content

Instantly share code, notes, and snippets.

@sumitasok
Last active August 29, 2015 14:19
Show Gist options
  • Save sumitasok/b05ea4ec82a02a79836e to your computer and use it in GitHub Desktop.
Save sumitasok/b05ea4ec82a02a79836e to your computer and use it in GitHub Desktop.
Shell Script collection
# add a string in a field to line number (15)
perl -pi -e 'if($.==14){s/\n/\n\/\/ ABC\n/g}if(eof){$.=0}' Makefile.txt
# replace regex with environment variable
perl -pi -e 's/(([0-9]+.){3}([0-9]+))/'$dIPmysql'/g' t.sh
# find the PID of the process that holds the port specified
lsof -i :7000 | awk 'FNR == 2 {print $2}'
lsof -i :8000 | awk 'FNR == 2 {print $2}' | xargs kill -9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment