![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to compare null and space using single if condition | jayakumarrt | UNIX for Dummies Questions & Answers | 3 | 05-16-2008 05:13 AM |
| Replace blank spaces by single tab, and right alignment | Jae | Shell Programming and Scripting | 1 | 08-08-2007 10:58 PM |
| how to read double consecutive space in filename for bash shell | james_falco | UNIX for Dummies Questions & Answers | 1 | 07-17-2007 04:32 PM |
| replacing single space in argument | convenientstore | Shell Programming and Scripting | 7 | 04-25-2007 01:02 PM |
| single input shell script? | quipy | Shell Programming and Scripting | 1 | 10-03-2002 08:18 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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? |
|
||||
|
That may have been a typo on my part. My program does write to output ok except for the fact that the double space comes out as a single space.
I'm going to ditch using the 'read' command and try using a combination of cat, grep and awk to rip through the file. If I do a : REC_BUF=`grep '^' $1` and then output to screen, the 2 spaces appear. Therefore I know it's a 'read' specific feature. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|