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 -->
  #7 (permalink)  
Old 05-13-2009
limshady411 limshady411 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Arizona
Posts: 10
Thanks Jim. This looks like it would do the trick. I can't get it working with my code though. I started using this:
Code:
while IFS=',' read first rest
do
  printf "%07d,%s\n" $first "$rest" >> newfile.csv
done< file.csv
which will pad the first field. But I would like to pad the second field. How do I get the code above to pad the second? Thanks much!

Here's the input file:
"100","100","ABC"
"100","200","ABC"
"100","300","ABC"

Here's the desired output:
"100","0000100","ABC"
"100","0000200","ABC"
"100","0000300","ABC"