How do i remove leading blank spaces from a single line using sed?



  • To remove leading blank spaces on a line using sed use this substitution.

    Line use with leading spaces.

          This is my line with leading spaces.
    

    First just echo the line to see what you get.

    $ echo "      This is my line with leading spaces."
          This is my line with leading spaces. 
    
    $ echo "      This is my line with leading spaces." | sed "s/^[ \t]*//"
    This is my line with leading spaces.
    


© Lightnetics 2024