Many Linux/Unix commands are shown formatted like ps -ef
for instance. As such it becomes difficult to process them subsequently in the pipeline, like for instance passing it to xargs kill
for killing the filtered errant processes. The command below, when part of a bash / sh pipeline will remove the leading and following spaces as well as convert multiple spaces to a single space inside string:
awk '{$1=$1;print}'
or shorter:
awk '{$1=$1};1'
Do you have such handy commands / snippets you would like to share? Please share in the comments below.
Categories