Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing field from csv file 1

Status
Not open for further replies.

ianicr

IS-IT--Management
Nov 4, 2003
230
GB
I have a csv file with names and addresses eg.
Mr,Smith,1,New Street,Birmingham

Is there an easy way of removing the third comma to make the file
Mr,Smith,1 New Street, Birmingham

Thanks
 
sed 's/,/ /3' filename > output should do it (a trick I learned from SamBones). :)


Annihilannic.
 
One last thing, how do you do it with a tab delimited file?
 
sed 's/,/ /' infile > outfile
will replace the first , found with a space, irrespective of the delimiter

Dickie Bird (:)-)))
 
With a Tab delimited file:
Code:
sed 's/   / /3' filename > output
       ^^^
       Single Tab char

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top