LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Bash select statement and spaces (https://www.linuxquestions.org/questions/linux-general-1/bash-select-statement-and-spaces-54160/)

meshcurrent 04-09-2003 05:51 AM

Bash select statement and spaces
 
I am trying to do a select statement with an item list that I read from a text file. The text file looks like:

Joe\ Shmo
John\ Smith

I am having trouble getting the select statement to treat first and last name as a single item:

select person in $(< person.list)
do
# ...
done

I tried backslashes and quotes, but that did not help.

Thank you for any help.

Youssef Eldakar
Bibliotheca Alexandrina

unSpawn 04-09-2003 07:19 AM

It's because ${IFS} lists a space as separator.
OLD_IFS=${IFS}; IFS="
"; select person in $(cat list) quit; do printf "%s${person}\n"; break; done; IFS=${OLD_IFS}

meshcurrent 04-09-2003 09:35 AM

Thanks!


All times are GMT -5. The time now is 08:06 AM.