Skip to content

Instantly share code, notes, and snippets.

@asela38
Last active October 8, 2018 05:07
Show Gist options
  • Save asela38/5c4a199b755d4c8376006e2b9049dfdb to your computer and use it in GitHub Desktop.
Save asela38/5c4a199b755d4c8376006e2b9049dfdb to your computer and use it in GitHub Desktop.

Take all properties from a pojo and enclose them inside a tag

$ grep private myPojo.java  | cut -d' ' -f7 | sed -e 's$\(.*\);$<value>\1</value>$g' 

Kill all processors which mactch a perticular user

$ ps ef | grep user123 | cut -d' ' -f2- | sed 's/^\s*//g' | cut -d' ' -f1 | grep "[0-9]" | xargs -n1 kill -9 
  • ps ef - report all processors (e-Write information for all the processors , f-Generate Full listing)
  • grep user123 - print lines only have text 'user123'
  • cut -d' ' -f2 - split line with ' ' (space) and take all after 2nd
  • sed 's/^\s//g'* - replace all leading multiple spaces
  • cut -d' ' -f1 - split line with ' ' (space) and take first column
  • grep "[0-9]" - find lines with integer
  • xargs -n1 kill -9 - for each line execute the command Kill -9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment