Suppose you have the following script:
#!/usr/bin/ksh
for element in $@
do
echo $element
done
And you execute the script using:
./myscript.ksh "my element"
The expected output should be:
my element
but the whitespace is treated as a separator for each argument, obtaining:
my
element
How should I escape the whitespace?
Thanks
You must either quote the $@
, or use nothing:
for element in "$@"
or
for element
will both work.