小编NNO*_*OPP的帖子

如何组合2个bash命令和print0包括在内

Bash版本:3.5

我有2个最喜欢的命令,我使用了很多

这是我的代码

  1. find . -type f -print0 | xargs -0 md5sum -b

  2. find . -type f -print0 | xargs -0 stat -c "%y"

如何将它们组合起来并得到与我的期望相似的结果.

结果:

4d452a2b17f0a6ea9408f959ad7a28a35d67c810 2016-06-28 16:09:34.000000000 211 ./DEW-FILES_COPY_2016-06-28_16092425_.bat

unix linux shell

1
推荐指数
1
解决办法
63
查看次数

如何在Linux bash的'find'命令中修复路径包含空格

我必须在Linux中使用路径包含空格字符,下面的命令对于非空间路径可以正常工作,但如果路径包含空格则会失败.

#!/bin/bash
for i in $( find "." -maxdepth 1 -mindepth 1 -type d ); do
    b=$(echo "$i" | awk '{print substr($1,3); }' )
    echo "This file contain <Modified date> <ActualSize Byte>   <FullPath>" > "$i"/"$b".txt
    find "$i" -type f ! -iname '*thumbs.db*' -print0 | xargs -0 stat -c "%y %s %n" >> "$i"/"$b".txt
done
Run Code Online (Sandbox Code Playgroud)

这是我的文件夹列表.

.
./Folder 1
./Folder 2
./Folder 3
Run Code Online (Sandbox Code Playgroud)

脚本的错误如下.

./xyz.sh: line 4: ./Folder/Folder.txt: No such file or directory
find: ./Folder: No such file or directory
./xyz.sh: …
Run Code Online (Sandbox Code Playgroud)

unix linux bash

0
推荐指数
1
解决办法
772
查看次数

标签 统计

linux ×2

unix ×2

bash ×1

shell ×1