Riz*_*sim 17
您正在寻找
diff -rq (dir1) (dir2)
Run Code Online (Sandbox Code Playgroud)
概念证明:
#!/bin/sh
#create our test
mkdir -p /tmp/a/b
echo "test" >> /tmp/a/c
mkdir -p /tmp/a/d/e
echo "blah" >> /tmp/a/d/e/f #only exists here
mkdir -p /tmp/q/b
echo "testing" >> /tmp/q/c #/tmp/a/c shouldnt match
mkdir -p /tmp/q/d/e
echo "blah" >> /tmp/q/d/e/g #only exists here
diff -rq /tmp/a /tmp/q
Run Code Online (Sandbox Code Playgroud)
结果是 :
Files /tmp/a/c and /tmp/q/c differ
Only in /tmp/a/d/e: f
Only in /tmp/q/d/e: g
Run Code Online (Sandbox Code Playgroud)
您只需要包含-q标志以使其简短:
# diff -q dir1 dir2
Files dir1/both and dir2/both differ
Only in dir1/: one
Only in dir2:/ two
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1923 次 |
| 最近记录: |