Bash Tricks: Sed One-Liners and a Bonus

Delete Leading Spaces using Sed

sed -e 's/^[ ]*//'

Delete Leading Spaces and Tabs (White Space) using Sed

sed -e 's/^[\t ]*//'

Delete Trailing Spaces using Sed

sed -e 's/[ ]*$//'

Delete Trailing Spaces and Tabs (White Space) using Sed

sed -e 's/[\t ]*$//'

Convert all Tabs to Spaces (The Bonus)

tr '\011' '\040'

About Pratik Sinha

Linux Nerd, Socialist, Atheist, Adventuristic, Nature Lover, Geeky.

Leave a Reply

Your email address will not be published. Required fields are marked *