Is there an option I can use in this command to return each result on a new line instead of just separated by a space?
echo $(ps ax | awk '/usr/ {print $5}')
Is there an option I can use in this command to return each result on a new line instead of just separated by a space?
echo $(ps ax | awk '/usr/ {print $5}')
awk 'BEGIN{while("ps ax"|getline){if($5~/^\/usr\//){print $5}}}'
alternative approach
ps -ax|awk '{if($5~/^\/usr\//){print $5}}'
The proper way to do it is simply:
ps ax | awk '/usr/ {print $5}'
If you want to keep your original form with echo
(but I think it's pointless), then you'd have to quote the subshell result:
echo "$(ps ax | awk '/usr/ {print $5}')"