【问题标题】:linux cp cannot stat 'no such file or directory' when using | in adblinux cp 使用时无法统计“没有这样的文件或目录”|在亚行
【发布时间】:2021-09-09 05:56:28
【问题描述】:

在手机中我安装了busybox并在ubuntu上使用adb命令 我想列出文件名并更改

在目录 /mnt/shared/Pictures asdf14 中,存在 ddr.txt

这么写

adb shell busybox find /mnt/shared/Pictures -name asd* | sed -e 'p' -e 's/asd/kkk/' | xargs -n 2 cp

但错误有效:cp: cannot stat '/mnt/shared/Pictures/asdf14' : No such file or directory

当切割 xargs 部分时,“adb shell busybox find /mnt/shared/Pictures -name asd* | sed -e 'p' -e 's/asd/kkk/' 它显示

/mnt/shared/图片/asdf14

/mnt/shared/图片/kkkf14

表示文件目录没有错,肯定存在

当我也使用向 txt 添加字符串时 adb shell busybox find /mnt/shared/Pictures -name asd* | echo > /mnt/shared/图片/ddr.txt 或 adb shell busybox find /mnt/shared/Pictures -name asd* -exec echo {} > /mnt/shared/Pictures/ddr.txt

但发生错误 /mnt/shared/Pictures/ddr.txt : 没有这样的文件或目录

它存在并在命令 ls 或 find 时发生。

当我输入 directory all 时它可以工作。 adb shell cp /mnt/shared/Pictures/asdf14 /mnt/shared/Pictures/asdf14444 它有效。

使用|时出现错误

我该如何解决?我想使用列出目录中的 echo 或 cp 请帮忙

我不能在busybox中使用“重命名”

【问题讨论】:

  • 欢迎来到 SO。您应该使用tour 并阅读How to Ask。然后编辑您的问题并对其进行格式化,以便于阅读。前任。以代码格式输入您的命令。现在是边缘胡言乱语。见stackoverflow.com/help/formatting
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
  • @james-kim 下面的答案是否有助于解决问题?

标签: linux bash shell adb


【解决方案1】:

即使findsed 命令的输出没问题,xargs 在你的ubuntu 机器上执行,这就是你得到的原因

No such file or directory

错误。

您应该尝试用双引号将整个命令括起来,以便在模拟器/设备上执行所有操作。

adb shell "busybox find /mnt/shared/Pictures -name asd* | sed -e 'p' -e 's/asd/kkk/' | xargs -n 2 cp"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-06
    • 2021-12-27
    • 2016-04-11
    • 2017-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多