Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将两个目录与:
diff --brief -s dir1/ dir2/
效果很好,我得到了以下输出:
Only in dir1/: test1 Files dir1/test2 and dir2/test2 differ Only in dir2/: test3 Files dir1/test4 and dir2/test4 are identical
是否有可能获得列出的文件 test1...test4 的输出ls -l dir1/?
ls -l dir1/
您可以创建一个 awk 脚本来为您执行此操作,例如
diff --brief -s dir1/ dir2/ | awk ' /^Only in/ { system("ls -l " gensub(":$","","1",$3) $4) } /^Files/ { system("ls -l " $2 " " $4) }'
但这给出了与 ... 相同的结果(顺序错误)ls -l dir1/ dir2/(因为 diff 输出每个文件。所以您可能需要重新指定您的要求。(并向我们展示您尝试过的内容...)
ls -l dir1/ dir2/