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!

Insert characters in $3 field

Status
Not open for further replies.

newlife01

MIS
Oct 23, 2004
3
US
I would like to know how to insert three 0 in the beginning of the third field in a csv file. The data would be someting like:

XV0126578,RGBYX,1234567
NV4567802,GYXTV,2345678

What I am looking for is to have

XV0126578,RGBYX,0001234567
NV4567802,GYXTV,0002345678

I am using this in a command line option and need to keep the out to a new file in the same order. Something similar to

cat testcsv.csv | awk -F, '{OSF=","; print $1, $2, $3}' >>outputfile.csv

 

[tt]
awk -F, '{OFS=",";$3="000" $3; print}' testcsv.csv >>outputfile.csv
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top