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

append a sequence id to all records 2

Status
Not open for further replies.

mwesticle

Programmer
Nov 19, 2003
51
US
Hi... I have a fixed-length file, and I need to append a 38-byte sequence id (starting with '00000000000000000000000000000000000001') to the beginning of each record. I know there is an easy way to do this using a korn shell script, but I can't remember it. Can anyone help me out here? Thanks!
 
Something like this ?
awk '{printf "%038d%s\n",NR,$0}' /path/to/input >output

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
That's great! One more question... How would I do the same thing on another fixed file, this time starting with '10000000000000000000000000000000000001'? Any ideas? Thanks again!
 
Try this -

awk {'printf "1%037d%s\n",NR,$0}' /path/to/input > output.


I am assuming that you still need a 38-byte sequence.


HTH,

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top