我有一堆文本在线条在一个文本文件中删除前导空格
例如的开头的文件,虽然它们都有空间
testing 123
download
upload
将是
testing 123
download
upload
优选地使用工具如grep的等
我有一堆文本在线条在一个文本文件中删除前导空格
例如的开头的文件,虽然它们都有空间
testing 123
download
upload
将是
testing 123
download
upload
优选地使用工具如grep的等
sed -i -e's/^\s*//' yourfilenamehere
可以使用sed
sed 's/^ *//' file
这应该适用于Linux和GNUWin Toolkit。
echo " Line starting with spaces" | sed 's/^[ \t]*//'
对于linux和windows,答案会有所不同。你能删除它们中的一个标签吗(除非你碰巧需要两个操作系统的答案) – matzahboy 2011-06-03 13:20:15
你是否想要做到这一点(即覆盖原始文件)或新文件(所以你保留原件)? – Richard 2011-06-03 13:21:02
@matzahboy取决于你使用的是什么,我的perl解决方案是跨平台的。 – Raoul 2011-06-03 13:21:27