Skip to content
Advertisement

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$

How do I fix this to get find . -type f -name "*" ‘s result?

Advertisement

Answer

I suggest to use an array:

filter_option=(-name '*')
file_paths=$(find "." -type f "${filter_option[@]}")
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement