I'm interested in storing an address in a variable called "address" using the read
command in a Bash script. However, I'm having an issue with the multiple words an address usually has. Is there a way to store several words into one variable instead of just one? For example:
echo "Please enter your address"
[user puts in 123 Fake street]
read address
echo $address
[output is just 123]
Normally
read address
should read the entire line of input into the variable. The most probable cause of the different behavior in your case is thatIFS
has been changed from its default value. If you change the line to this, it should work:And I suggest to review your entire script for places that alter
IFS
, and if possible, avoid changing it.