【发布时间】:2019-02-18 15:38:43
【问题描述】:
我需要对很多目录中的很多文件执行一些操作,比如检查它们是否受密码保护。
我创建了一个 bash 脚本 (fileproc.sh),我想检查它是否有效,所以我做了一件愚蠢的事情来看看它是否有效:
#!/bin/sh
echo 'File: ' + $1
如果我运行一个简单的
find . -name "*.zip" -type f
正如预期的那样,我有一长串 .zip 文件。
如果我跑了
find . -name "*.zip" -type f -print0 | xargs ./fileproc.sh
我只有三个文件。
我做错了什么?
谢谢
【问题讨论】:
-
在脚本中使用
xargs -0和print0并使用:echo "File: $1"