我正在尝试使用 sed 从此文件中删除等号并将其通过管道传输到新文件:
I am a file to be edited.
A unique file with my own words.
T=h=e=r=e a=r=e i=s=s=u=e=s w=i=t=h t=h=i=s l=i=n=e
Run Code Online (Sandbox Code Playgroud)
我试过了,cat FixMeWithSed.txt | sed 's/=//' > FileFixedWithSed.txt
但它只替换了第一个等号。
I am a file to be edited.
A unique file with my own words.
Th=e=r=e a=r=e i=s=s=u=e=s w=i=t=h t=h=i=s l=i=n=e
Run Code Online (Sandbox Code Playgroud)
我不知道如何选择所有等号,而不仅仅是第一个。谢谢!
你必须使用的g
标志做摹叶形的替代品。否则,它只会发生一次。
cat FixMeWithSed.txt | sed 's/=//g' > FileFixedWithSed.txt
Run Code Online (Sandbox Code Playgroud)
顺便说一句,sed
可以从文件中读取,所以你不需要cat
这里:
sed 's/=//g' FixMeWithSed.txt > FileFixedWithSed.txt
Run Code Online (Sandbox Code Playgroud)