【发布时间】:2012-05-30 10:03:06
【问题描述】:
我有一个类似“test.txt”的文件:
hello world
它只是一个“hello world”字符串。如果我使用 perl 正则表达式:
perl -pe "s/hello/bye/g" test.txt
上面写着:
bye world
但如果我尝试将该文件重定向到自身:
perl -pe "s/hello/bye/g" test.txt > test.txt
结果文件为空。为什么?以及如何对文件“过滤”正则表达式?
【问题讨论】:
标签: linux shell command-line