This is sloppy I only have  a minute
Why use sed 
#!/bin/ksh
> ./outfile
cat ./infile | while read LINE
do
   Name=`echo $LINE | cut -f1 -d","`
   Add=`echo $LINE | cut -f2 -d","`
   Add2=`echo $LINE | cut -f3 -d","`
   City=`echo $LINE | cut -f4 -d","`
   State=`echo $LINE | cut -f5 -d","`
   Zip=`echo $LINE | cut -f6 -d","`
   Contact=`echo $LINE | cut -f7 -d","`
   echo $Name,$Add $add2,$City,$State,$Zip,$Contact >> ./outfile
done
------Original Message------
From: Trilochan Padhi <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: May 8, 2000 10:56:44 PM GMT
Subject: Re: Again a sed question



Have you tried changing the first comma to something like
'QJK', then changing the next comma to space, and finally
changing 'QJK' back to a comma?  (First make sure the character
string you use is not in your file.)


[EMAIL PROTECTED] wrote:
> 
> To All,
> 
> I should have been more specific. I'm trying to
> concatenate the second and third columns.
> Although I greatly appreciate all the quick answers, I've
> already tried all those I've seen, with the exception
> of the awk answer.
> 
> It's easy to change 2 comma's to one comma. I am trying
> to eliminate the second comma on each row and replace it
> with a space, thus combining column 2 and column 3, no matter
> what is contained in column 3 - numbers, letters, or nothing
> 
> __________________________________________________
> I have what appeared to me to be a simple problem.
> I went out and bought the sed & awk book (O'Reilly) and
> went at it. About 7 or 8 hours later, I stopped going at it :-(
> 
> I have a simple CVS file that looks like this:
> 
> Name,Add,,City,State,Zip,Contact
> Joe Inc,123 Main,,Brown,NY,12345,Joe
> Pete Inc,456 7th,PO Box 1,Green,NY,12346,Pete
> Jack Inc,789 1st,Bldg 5,Red,NY,12347,Jack
> 
> If you noticed, the 2nd and 3rd columns are both
> address columns. The third column varies and may
> be empty, start with a number or small/Capital letter.
> 
> All I want to do is eliminate the second , (comma) and replace it
> with a space. Unfortunately I'm not strong in regular
> expressions and everything I have tried so far isn't working.
> There are over 30,000 records in this file. I would
> much rather watch sed do it in 15 or so seconds than spend
> 15 or so days doing it by hand.
> 
> Can someone help me with this?
> 
> Thanks
> 


> John C.
> 
> "All my life I wanted to be someone;
> I guess I should have been more specific."
> 
> ________________________________________________________________
> YOU'RE PAYING TOO MUCH FOR THE INTERNET!
> Juno now offers FREE Internet Access!
> Try it today - there's no risk!  For your FREE software, visit:
> http://dl.www.juno.com/get/tagj.

Reply via email to