File1:
hello world
How would one delete the leading/trailing blank spaces within this file using sed - using one command (no intermediate files)?
I've currently got:
sed -e 's/^[ ]*//' a > b
For leading spaces.
sed 's/ *$//' b > c
And this for trailing spaces.
You almost got it:
sed -e 's/^[ ]*//;s/[ ]*$//' a > c
Moreover on some flavours of sed, there is also an option for editing inline:
sed
sed -i -e 's/^[ ]*//;s/[ ]*$//' a
1.4m articles
1.4m replys
5 comments
57.0k users