android - 找到 : combining multiple "-exec" statements not working with toybox/Android?

标签 android linux shell toybox

我正试图在运行 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/

相关文章:

c - write() 返回 errno 14 为什么?

linux - 如何让 bash 变量在 awk 管道上工作

asp.net - asp.net中的命令提示符和asp中的执行文件

android - 为 textView Android 设置文本颜色

android - overridePendingTransition:在 Activity 中从右到左滑动深度

c - kprintf 打印出正楷

linux - 使用 awk 获取特定的字符串

android - addProximityAlert 不起作用(requestLocationUpdates 也不起作用)- Android

android - 如何在不包含 android 支持库的情况下使用 ADT r20 创建 n 个项目?

bash - 使用名称模式 *.[a-z0-9].bundle.* 重命名所有文件,以将 [a-z0-9] 替换为给定字符串