Linux shell编程学习笔记(八) 文件
程序员文章站
2022-07-03 11:59:38
...
1、comm比较命令
[email protected]:~/work/tq210/shell$ cat aa
line1
line2
line3
[email protected]:~/work/tq210/shell$ cat bb
line1
line2
line4
[email protected]:~/work/tq210/shell$ comm aa bb
line1
line2
line3
line4
[email protected]:~/work/tq210/shell$ comm -1 aa bb
line1
line2
line4
[email protected]:~/work/tq210/shell$ comm -2 aa bb
line1
line2
line3
[email protected]:~/work/tq210/shell$ comm -3 aa bb
line3
line4
[email protected]:~/work/tq210/shell$ comm -13 aa bb
line4
其中,-1 表示不显示只在文件1中出现的列,-2 表示不显示只在文件2中出现的列,-3 表示不显示两个文件相同的列
2、diff比较命令
[email protected]:~/work/tq210/shell$ cat file1
line1
line2
line3
[email protected]:~/work/tq210/shell$ cat file2
line1
line2
line4
[email protected]:~/work/tq210/shell$ cat file3
line1
line2
[email protected]:~/work/tq210/shell$ diff file1 file2
3c3
< line3
---
> line4
[email protected]:~/work/tq210/shell$ diff file1 file3
3d2
< line3
[email protected]:~/work/tq210/shell$ diff file3 file1
2a3
> line3
第一个表示文件1的第3行和文件2的第3行受影响,如果文件1要改为文件2,应把文件1的第3行line3,换成文件2的第3行line4
第二个表示文件1的第3行和文件3的第2行受影响,如果文件1要改为文件3,应把文件1的第3行line3删除
第三个表示文件3的第2行和文件1的第3行受影响,如果文件3要改为文件1,应把文件3的第3行添加line3
3、制作补丁文件
diff 未修改代码文件夹 修改好代码文件夹 > 生成的补丁文件
4、使用补丁文件
先进入要打补丁代码的文件夹,补丁文件放在上一层目录
patch -p1 < ../补丁文件
上一篇: ModelAndView
下一篇: ModelAndView