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!

Change column data

Status
Not open for further replies.

longs

Programmer
Jul 27, 2007
31
US
Hi ALL

I got few columns which are varchar2(4) at the moment they have values like 01, 54, 39. in short they are two digits i want to convert them into four digits like 0001, 0054,0039.


col1 col2 col3
04 39 54
57 89 99
78 56 89

convert it to :
col1 col2 col3
0004 0039 0054
0057 0089 0099
0078 0056 0089

What can I do?

Thanks to all
 
nawk -f longs.awk myFile

longs.awk:
Code:
FNR>1 {
   for(i=1; i<=NF; i++)
     $i=sprintf("%04d", $i)
}
1

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top