2016-03-21 39 views
1

操作系统:Linux RedHat的如何使用多个bash的命令在单个线路

击:3.5

我有下面两个命令来获得与他们的地位和足迹另一个命令的文件列表。 我想找到将它们组合在一条线上的方法。

这是我提到的命令。

  1. find "$PWD" -type f ! -iname '*thumbs.db*' -print0 | xargs -0 stat -c "%y %s %n"

  2. find "$PWD" -type f -print0 | xargs -0 sha1sum -b

回答

1

将这项工作?在xargs上执行man

find $PWD -type f ! -iname '*thumbs.db*' -print0 | xargs -0 -I '{}' sh -c 'stat --printf "%y %s %n " {} ; sha1sum -b {}' 

如果您不希望文件名重复两次:

find $PWD -type f ! -iname '*thumbs.db*' -print0 | xargs -0 -I '{}' sh -c 'stat --printf "%y %s %n " {} ; sha1sum -b {} | cut -d\ -f1' 

需要有d\cut 2个空格之后的命令。

+0

它的工作,但没有把结果放在一起作为名单。 – NNOPP

0

你可以用find命令本身的-exec来做到这一点。

find $PWD -type f ! -iname '*thumbs.db*' -exec stat -c "%y %s %n" {} \; -exec sha1sum -b {} \; 
+0

感谢这一个伟大的作品。 – NNOPP