LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 04-09-2003, 06:51 AM   #1
meshcurrent
Member
 
Registered: Oct 2002
Posts: 38

Rep: Reputation: 15
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
 
Old 04-09-2003, 08:19 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,709
Blog Entries: 54

Rep: Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965Reputation: 2965
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}
 
Old 04-09-2003, 10:35 AM   #3
meshcurrent
Member
 
Registered: Oct 2002
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash assignment - using a grep inside an if statement lowpro2k3 Programming 4 03-25-2005 06:24 PM
bash statement os2 Programming 2 03-20-2005 11:13 PM
bash if statement question xscousr Programming 3 09-02-2003 12:58 PM
Need help adding an IF / ELSE statement to my Bash Script Relix Linux - General 1 08-01-2002 03:03 PM
bash for statement with 2 arrays? Noerr Linux - General 10 05-27-2002 01:58 PM


All times are GMT -5. The time now is 01:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration