The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-09-2005
TheCrunge TheCrunge is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 30
Processing a text file

A file contains one name per line, such as:


Code:
john doe
jack bruce
nancy smith
sam riley

When I 'cat' the file, the white space is treated as a new line. For example


Code:
list=`(cat /path/to/file.txt)`
for items in $list
do
echo $items
done

I get:


Code:
john 
doe
jack 
bruce
nancy 
smith
sam 
riley

How can I get each line to be echoed (so the full names are on their own line), not each item separated by whitespace?

Thanks