Skip to content

Instantly share code, notes, and snippets.

@MichalMazurek
Last active April 5, 2019 10:53
Show Gist options
  • Save MichalMazurek/2dc7ab48594324c1d587c1aa619af410 to your computer and use it in GitHub Desktop.
Save MichalMazurek/2dc7ab48594324c1d587c1aa619af410 to your computer and use it in GitHub Desktop.
# print only nth column from output
ps ax | awk '{printf "%s\n", $5}'
zsh
ps
tail
awk
# join each line with ","
cat file.txt | awk '{printf (NR>1?",":"") $0}'
wheel==0.24.0,
XlsxWriter==0.9.1,
gunicorn,
pandas,
sqlparse
# join each line with "," and surround with "'"
cat file.txt | awk '{printf (NR>1?",\n":"") "\x27%s\x27", $0}'
'wheel==0.24.0',
'XlsxWriter==0.9.1',
'gunicorn',
'pandas',
'sqlparse'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment