Shell脚本-directory compare-输出
问题描述:
我比较两个目录有:Shell脚本-directory compare-输出
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/
呢?
答
您可以创建一个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/
...(因为差异输出,在每个文件。所以,你可能(并告诉我们你还有什么要试试...)
你能解释一点点你正在试图做什么吗?这个问题很难理解 – hek2mgl 2013-04-23 17:22:29
我的理解是:你有一个文件列表(从你的差异或任何地方)并调用'ls -l'。究竟是什么问题? – 2013-04-23 17:28:57
对不起,描述不对。修复它并添加更多信息。 – wes 2013-04-23 18:17:03