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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sequential numbers 1

Status
Not open for further replies.

ianicr

IS-IT--Management
Nov 4, 2003
230
0
0
GB
I have a file which contains several prefixes. eg.

123
124
132
143
145
163
317

I need to create a new file with
1230000
1230001
1230002
1230003
1230004
1240001
1240002
1240003
1240004

for each number in the first file. Anyone got any ideas how this would be possible? I've been racking my brains and I can't think of anything. Any help would be greatly appreciated. Thanks
 
I'm sure someone else will come up with a wizzy awk solution but this does work :)

Alex

cat file | while read NUM
do
echo $NUM"0000" >>file99
echo $NUM"0001" >>file99
echo $NUM"0002" >>file99
echo $NUM"0003" >>file99
echo $NUM"0004" >>file99
done
/tmp > cat file99
1230000
1230001
1230002
1230003
1230004
1240000
1240001
1240002
1240003
1240004
1250000
1250001
1250002
1250003
1250004
1260000
1260001
1260002
1260003
1260004
 
Something like this ?
awk '{for(i=0;i<=4;++i)printf "%s%04d\n",$1,i}' /path/to/prefix >newfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thats ACE!!! Thanks you saved my life!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top