Unix questions - Re: Unix Need Help with auto incrementing a field between delimiter.

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > November 2005 > Re: Unix Need Help with auto incrementing a field between delimiter.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Unix Need Help with auto incrementing a field between delimiter.
Rainer Temme

2005-11-30, 5:55 pm

AMBROZE schrieb:
> This is what I currently have, but it replaces all instances in the
> file with the value of $cnt.
>
> cnt=000000001
> awk 'BEGIN {FS = "[*~]" ; OFS = "*" }
> {
> $3 = "'$cnt'"
> print $0
> }' $file


Hi Ambroze,

how about the following modification:

awk 'BEGIN {FS = "[*~]" ; OFS = "*" ; CNT=1; }
{
$3 = sprintf("%09d",CNT++);
print $0
}' $file


Regards ... Rainer
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com