I'd like to cut extra spaces from "ps aux" output and replace them with one space. What I do is:
ps axu | sed 's/[ ]+/ /g'
But output seems to be unchanged, I still get too much spaces between tokens.
username 4876 ... <the rest of columns ommitted>
Why this regular expression doesn't match empty space between username and pid?
Because sed
uses basic regular expressions (BRE), and +
isn't part of them. Use s/ */ /
(two spaces in the pattern part), or -E
for extended regular expressions in GNU or BSD sed
: sed -E 's/ +/ /g'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments