我想将 find 命令的结果放到变量中 - 我在命令替换块中遇到变量问题。波纹管简短的例子:
#!/bin/bash
pattern='"file*"'
res=$(find . -maxdepth 1 -type f -name ${pattern}) # doesn't work
#res=$(find . -maxdepth 1 -type f -name "file*") # works
echo $res
怎么了?
我想将 find 命令的结果放到变量中 - 我在命令替换块中遇到变量问题。波纹管简短的例子:
#!/bin/bash
pattern='"file*"'
res=$(find . -maxdepth 1 -type f -name ${pattern}) # doesn't work
#res=$(find . -maxdepth 1 -type f -name "file*") # works
echo $res
怎么了?