如果我运行此命令,它在终端中可以正常工作:
for dirname in $(ls -d dir/checkpoint/features.txt/20*);do;echo "hello";done
但是当通过 /bin/sh -c 运行时,它会给出一个错误
/bin/sh -c "for dirname in $(ls -d dir/checkpoint/features.txt/20*);do;echo "hello";done"
错误:
/bin/sh: -c: line 1: syntax error near unexpected token `dir/checkpoint/features.txt/201108000'
/bin/sh: -c: line 1: `dir/checkpoint/features.txt/201108000'
我的默认 shell 是 /bin/bash。我似乎无法理解是什么原因造成的。我在程序中运行所有 shell 命令的默认实现是将 /bin/sh -c 附加到它们。这是我第一次看到这个问题。有什么建议么?