I just started learning Bash Script.
My script is accepting 1 to n number of arguments. Each argument is pass to a function rename. My problem is that the argument I pass does not accept space.
script.sh
#!/bin/bash
for FILE in $@
do
echo "$FILE"
rename $FILE
done
For Ex:
./script.sh /Users/xyz/Section 5/abc/ /Users/xyz/pqr/ /Users/z/abc
The above argument "/Users/xyz/Section 5/abc/" should be one even if it contains space. But the code in script.sh will break it into two argument.
So the output is:
/Users/xyz/Section
5/abc/
/Users/xyz/pqr/
/Users/z/abc
But My Expected Output should be:
/Users/xyz/Section 5/abc/
/Users/xyz/pqr/
/Users/z/abc
Note: Different solution I tried till now:
1) "/Users/xyz/Section 5/abc/" --> Same output ie 2 different argument
2) '/Users/xyz/Section 5/abc/' --> Same output ie 2 different argument
3) /Users/xyz/Section\ 5/abc/ --> Same output ie 2 different argument