Need help getting input from a file.
Hi everybody! I've been trying to figure this out for the past couple of days and I'm stumped...
I am trying to input from a file. The file's layout has three columns; a department number, a first name and a last name, each separated by a space, for example: Code:
781-89-4271 Amy Balduff Code:
#!/bin/bash 781-89-4271 781-89-4271 781-89-4271 Amy Amy Amy Baldruff Baldruff Baldruff instead of : 781-89-4271 Amy Baldruff I need to input the words through separate variables because I will be passing them to other programs as soon as I can figure this out. Any help?? |
Hi, welcome to LQ!
Can you post a bit of sample input via copy & paste? And may I suggest that you use code-tags for both your script & the data ... Like [ code ] and [ /code ] , just w/o the spaces between the brackets and code & /code respectively. Cheers, Tink |
Okay, I re-posted it with the tags.
|
Ok, didn't see you edited your initial post
How's this? Code:
#!/bin/bash |
Thank you! it works, and it's so much simpler.
One question though, what does the ' < $file ' part do on the last line? Is it just part of the syntax of a while loop? |
Quote:
feeding the read in the while loop. Cheers, Tink |
And for the record: to make your version work all it would have taken
was to introduce a new IFS ... I just thought the more elegant way was preferable. Code:
#!/bin/bash Cheers, Tink |
All times are GMT -5. The time now is 12:13 AM. |