我在cmdline中有以下行
sed -e '1s/^/\\documentstyle\[11pt\]\{article\}\n/' -e 's/[0-9]//g' test.txt
我想要的输出是这样的
\documentstyle[11pt]{article}
rest of the file
但是我只能得到这个
\documentstyle[pt]{article}
rest of the file
我似乎找不到插入数字的方法。我试过反斜杠。解决方案可能很简单,但我是sed的新手。
答案 0 :(得分:1)
请注意sed has more commands而非s///
。要在文件顶部插入一行:
sed -e '1i\
\\\documentstyle[11pt]{article}' -e 's/[0-9]//g' file
(令人沮丧的是,通过反复试验找到了输出中反斜杠的反斜杠数量)
奖金不会影响您删除号码的目标。
答案 1 :(得分:0)
我的第二个命令是删除数字,确实按预期工作,但我只是想立刻完成所有操作。致Jonathan Leffler的信用。