I am having issues handling arguments that contain white spaces in a my bash script.
The script
#!/bin/bash
for i in $*
do
echo "$i"
done
The call (with 2 arguments)
$ ./script.sh "a b" "c"
The actual output (as if there were 3 arguments)
a
b
c
The expected output (as if there were 2 arguments)
a b
c
Can someone explain how to get the expected output?
Change $* to "$@" on the first line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With