The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
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 08-31-2007
NinersFan NinersFan is offline
Registered User
  
 

Join Date: Aug 2007
Location: Toronto
Posts: 3
Consecutive spaces within input being converted to single space

I'm reading from a file that is semi-colon delimited. One of the fields contains 2 spaces separating the first and last name (4th field in - "JOHN<space><space> DOE"):

e.g. TORONTO;ONTARIO;1 YONGE STREET;JOHN DOE;CANADA

When I read this record and either echo/print to screen or write to output, the 2 spaces get converted to a single space. I need to keep all spaces intact when writing to output.

Here's a snippet of code I'm using. I'm attempting to load a series of records into an array with the purpose of performing logic on the contents and then outputting to several different output(s):

exec 3<$1 # Open input
exec 4>$1.out # Open output
let CNF_REC_CNT=CNF_REC_CNT+1
read -u3 REC_BUF[CNF_REC_CNT]
print "Buffer is : "${REC_BUF[CNF_REC_CNT]}""

How do I get around this?