我正试图在运行 Oreo/8.0 和 toybox 0.7.3-android 的 Android 手机上解决这个问题。
我正在尝试获取文件夹内的文件列表及其各自的 mtime。我正在运行这个命令:
find . -type f -exec stat -c %n {} \; -exec stat -c %y {} \;
或
find . -type f -exec stat -c %n "{}" \; -exec stat -c %y "{}" \;
在这两种情况下,我都只得到第一次调用“stat”的结果。我是在监督什么,还是玩具箱在 Android 上的工作方式?
最佳答案
如果 toybox 不能执行多个 exec
,还有其他选择。
在这种特殊情况下,您可以只使用一个统计数据:
find . -type f -exec stat -c "$(echo -e "%n\n%y")" {} \;
# or just insert the newline verbatim in single quotes:
find . -type f -exec stat -c '%n
%y' {} \;
用于运行多个命令(假设路径不包含换行符):
find . -type f -print | while IFS= read -r f; do
stat -c $n "$f";
stat -c %y "$f";
done
关于android - 找到 : combining multiple "-exec" statements not working with toybox/Android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55343812/