gpt4 book ai didi

linux - 如何在一行中使用多个 bash 命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:46:50 24 4
gpt4 key购买 nike

操作系统:Linux RedHat

重击:3.5

我在下面有 2 个命令来获取文件列表及其状态,另一个命令用于获取足迹。我想找到将它们组合成一行的方法。

这是我提到的命令。

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

  2. 找到“$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'

cut命令中d\后需要有2个空格

关于linux - 如何在一行中使用多个 bash 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36122433/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com