Bash版本:3.5
我有2个最喜欢的命令,我使用了很多
这是我的代码
find . -type f -print0 | xargs -0 md5sum -b
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
我必须在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)