Delete whitespace in each begin of line of file, using bash

后端 未结 5 1177
迷失自我
迷失自我 2020-12-29 08:22

How i can delete whitespace in each line of file, using bash For instance, file1.txt. Before:

  gg g
 gg g
t  ttt

after:

gg         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-29 09:07

    tr(delete all whitespaces):

    $ tr -d ' ' output.txt
    $ mv output.txt input.txt
    

    sed(delete leading whitespaces)

    $ sed -i 's/^ *//' input.txt
    

提交回复
热议问题