我只是想把两个文件区别开来,然后将它们写入另一个没有补丁标签(如+或 - )或diff标签(如>或者<。我理解补丁的工作原理以及如何使用以下命令:
diff file1.txt file2.txt | grep ">" > difffile.txt
diff -u file1.txt file2.txt > difffile.patch
patch original.txt < difffile.patch
但是当我从第一个命令打开我的difffile.txt时,我得到这样的东西:
> some line of text
> some other line of text
当我真正想要的是:
some line of text
some other line of text
我认为可能将字符串索引为
${stringname:2}
可行,但我不知道如何使用grep或如何索引grep字符串。
我实际上正在解析html和xml,只想要某些文件中的值差异。我不知道该怎么做。
答案 0 :(得分:1)
如果您只想删除每行的前两个字符,cut
是您的朋友:
cut -c3- file
$ cat a
hello this is me
and this is you
$ cut -c3- a
llo this is me
d this is you