Table of Contents

SED - Delete - Delete leading whitespace (spaces, tabs) from front of each line

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

NOTE: Aligns all text flush left.

NOTE: The expression '\t' is used to indicate a tab character (0x09) in the scripts.

Some versions of sed do not recognize the '\t' abbreviation, so when typing these scripts from the command line, you should press the TAB key instead.

'\t' is supported as a regular expression.


Example

Running that command again this file:

testfile
aaa
 bbb
  ccc

returns:

testfile
aaa
bbb
ccc

Example

cat input.txt | sed 's/^[ \t]*//' > output.txt