![]() |
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 |
| Help needed in padding leading zeros | jakSun8 | Shell Programming and Scripting | 12 | 07-02-2008 07:41 PM |
| Byte Padding | naan | High Level Programming | 6 | 02-22-2007 05:09 AM |
| Padding zeros after removing commas in file | pranag21 | HP-UX | 1 | 11-09-2005 10:22 PM |
| Padding | vijaygopalsk | UNIX for Dummies Questions & Answers | 2 | 06-27-2003 10:51 AM |
| Padding issues | informshilpa | UNIX for Advanced & Expert Users | 2 | 03-01-2002 01:51 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Padding with zeros.
Hi Friends,
I would like to left pad with "0's" on first column say (width six) I have a large file with the format: FILE: 1: ALFRED 84378 NY 8385: JAMES 88385 FL 323: SMITH 00850 TX My output needs to be like: 000001: ALFRED 84378 NY 008385: JAMES 88385 FL 000323: SMITH 00850 TX Thanks in advance for your help |
|
||||
|
Padding with zeros
Hi all,
Referencing the awk statement here Code:
awk -F: '{ printf "%06d: %s\n", $1,$2 }' input.txt
Code:
awk -F, '{ printf "%06d, %s\n", $6,$7 }' test1.csv > test2.csv
Please advise. Thanks much! Lim |
|
||||
|
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 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" |
| Sponsored Links | ||
|
|