Reputation: 1879
I am making and script with positional parameters the parameters are $1 and $2, the name of the script is script.sh and looks like this:
#!/bin/bash
echo $1
echo $2
and i run it as follows bash script.sh '1 2' 3 in order to consider '1 2' as a single parameter, and i get the following output
1 2
3
since i am leading with parameters with spaces i want to find a way to obtain the same output without using the quotes inside the code, i would appreciate any suggestion
Upvotes: 0
Views: 39
Reputation: 531165
If you set IFS
to an empty string, word-splitting will be disabled.
$ foo="1 2"
$ IFS=
$ echo $1
1 2
However, I can't think of a good reason to do this rather than simply quoting the expansion.
Upvotes: 1