for loop 1 to 1 in bash -


i have issue loop:

for file in "$list"                     if [ ! -f "$file" ];                 final_list="$final_list $file"             fi         done  

in $list stored file file1 file2 file3 , need check each word if exist file name. works if have in $list more 1 word. if $list containst 1 word don't work. variable $final_list empty.

thank

the problem double quotes. prevent word-splitting on $list, $file contains whole $list.

but, condition checks non-existence, single file woudl failt condition, list 'file1 file2', file of name doesn't exist, whole list assigned $final_list.

try running script set -xv see what's going on.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -