If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Problems with read command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-10-03, 17:54
c_dilip c_dilip is offline
Registered User
 
Join Date: Oct 2003
Posts: 2
Problems with read command

Hi Guys,

I have a file with the following lines

123456789 123456789
123456789XXXXXXXXX123456789

All the X here are actually spaces in the actual file.


To read this file line by line , I used the following code.

file=test.dat
cat $file | while read line
do
echo $line
done

In the output, I get something like this

123456789X123456789. All but 1 space have disappeared. Actually I need the spaces in tact. Please let me know where I went wrong.

Thanks in advance.

Dilip
Reply With Quote
  #2 (permalink)  
Old 10-11-03, 05:37
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
while read line
do
echo "$line" # the quotes will prevent echo removing the extra spaces
done < test.dat
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On