我正在尝试运行git stripspace
,但documentation没有帮助。git stripspaces
似乎将stdin
作为其输入并写入stdout
,但:
% git stripspace < myfile.txt > myfile.txt
删除了myfile.txt
中的所有文本
我希望文档提供一个调用示例。有人有吗?
我正在尝试运行git stripspace
,但documentation没有帮助。git stripspaces
似乎将stdin
作为其输入并写入stdout
,但:
% git stripspace < myfile.txt > myfile.txt
删除了myfile.txt
中的所有文本
我希望文档提供一个调用示例。有人有吗?
2条答案
按热度按时间anauzrmj1#
您正在将从和**重定向到同一个文件。
这就是问题所在。
尝试更改您的简单命令,即:
改为:
它应该能正常工作。
arknldoa2#
sponge
正是解决这个问题的工具,它首先“吸收”所有输入的数据,然后将其写入指定的文件,它是moreutils
包的一部分-在Ubuntu上用sudo apt install moreutils
安装它,下面是一个使用文件
spacetest.txt
的示例-awk
命令用于帮助可视化文件中存在的尾随空格: