Linux CLI, Remove Leading or Trailing Spaces

A handy little snippet for removing leading or trailing spaces from lines of piped data :-

To remove leading spaces from each line in the piped data

somecmd | sed -e 's/^[[:space:\]]*//'

To remove trailing spaces from each line in the piped data

somecmd | sed -e 's/[[:space:]]*$//'
Friday 21 December 2012 at 09:31 am | | Linux

No comments

(optional field)
(optional field)

Comment moderation is enabled on this site. This means that your comment will not be visible until it has been approved by an editor.

Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.