TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Unix Learnings > [SOLVED] Unix: Removing Leading and Trailing spaces from a string- shell script

Sourav Gulati
Site Owner
Posts: 83

Leading spaces from value of a variable can be removed as follows:

$ echo $var | sed 's/^ *//g'

Trailing spaces from value of a variable can be removed as follows:

$ echo $var | sed 's/ *$//g'

--


January 9, 2013 at 4:52 AM Flag Quote & Reply

You must login to post.