delete leading whitespace (spaces, tabs) from front of each line

posted Feb 25, 2012, 6:27 AM by Sachchida Ojha   [ updated May 22, 2013, 9:15 AM ]
sed 's/^[ \t]*//'

[oracle@usha scripts]$ cat a                       # Original file
  Sachchida Nand Ojha   
  Andrew Bove
 
[oracle@usha scripts]$ cat a|sed 's/^[ \t]*//'    #deleted all leading space
Sachchida Nand Ojha   
Andrew Bove

[oracle@usha scripts]$ cat a|sed 's/^[ \t]//'       # Deleted one space
 Sachchida Nand Ojha   
 Andrew Bove

[oracle@usha scripts]$ cat a|sed 's/^[\t]*//'        # Does Nothing
  Sachchida Nand Ojha   
  Andrew Bove
 
[oracle@usha scripts]$


Comments