rule of thumb: put all your variables in ""
when you do something like this
Code:
i='abc 001.jpg'
convert $i -resize 25% $(basename $i)converted.jpg
after substitution you get this
Code:
convert abc 001.jpg -resize 25% ....
ie, multiple parameters where 1 is expected. Double quotes prevent that
Code:
$ i='abc 001.jpg'
$ printf "[%s]\n" $i
[abc]
[001.jpg]
$ printf "[%s]\n" "$i"
[abc 001.jpg]
printf puts its parameter(s) in place of %s placeholder(s) so it can be used to easily show the difference between $var and "$var".
Bookmarks