操作系统:Linux RedHat的如何使用多个bash的命令在单个线路
击:3.5
我有下面两个命令来获得与他们的地位和足迹另一个命令的文件列表。 我想找到将它们组合在一条线上的方法。
这是我提到的命令。
find "$PWD" -type f ! -iname '*thumbs.db*' -print0 | xargs -0 stat -c "%y %s %n"
find "$PWD" -type f -print0 | xargs -0 sha1sum -b
操作系统:Linux RedHat的如何使用多个bash的命令在单个线路
击:3.5
我有下面两个命令来获得与他们的地位和足迹另一个命令的文件列表。 我想找到将它们组合在一条线上的方法。
这是我提到的命令。
find "$PWD" -type f ! -iname '*thumbs.db*' -print0 | xargs -0 stat -c "%y %s %n"
find "$PWD" -type f -print0 | xargs -0 sha1sum -b
将这项工作?在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个空格之后的命令。
你可以用find命令本身的-exec来做到这一点。
find $PWD -type f ! -iname '*thumbs.db*' -exec stat -c "%y %s %n" {} \; -exec sha1sum -b {} \;
感谢这一个伟大的作品。 – NNOPP
它的工作,但没有把结果放在一起作为名单。 – NNOPP