开发者

Removing leading spaces in a text file

开发者 https://www.devze.com 2023-03-10 00:44 出处:网络
I have a bunch of texts files although they all have spaces at the beginning of lines e.g. testing 123

I have a bunch of texts files although they all have spaces at the beginning of lines

e.g.

 testing 123
 download
 upload

wo开发者_如何学Culd be

testing 123
download
upload

Preferably using a utility such as grep etc.


sed -i -e's/^\s*//' yourfilenamehere


You can use sed

sed 's/^ *//' file

This should work with Linux and your GNUWin Toolkit.

echo "     Line starting with spaces" | sed 's/^[ \t]*//'


perl -pi -e 's/^\s+//' yourfilenamehere
0

精彩评论

暂无评论...
验证码 换一张
取 消