为什么在 shell 脚本中打印空路径?
Why print empty path in shell script?
filter_option=" -name \"*\" "
file_paths=$(find "." -type f $filter_option)
echo find "." -type f $filter_option
echo $file_paths
samuel@:~/.../linux$ ./test.sh
find . -type f -name "*"
samuel@:~/.../linux$
如何解决此问题以获得 find . -type f -name "*"
的结果?
我建议使用数组:
filter_option=(-name '*')
file_paths=$(find "." -type f "${filter_option[@]}")
filter_option=" -name \"*\" "
file_paths=$(find "." -type f $filter_option)
echo find "." -type f $filter_option
echo $file_paths
samuel@:~/.../linux$ ./test.sh
find . -type f -name "*"samuel@:~/.../linux$
如何解决此问题以获得 find . -type f -name "*"
的结果?
我建议使用数组:
filter_option=(-name '*')
file_paths=$(find "." -type f "${filter_option[@]}")