Posted by Dave Kelly on 04/08/07 22:59
Chris F.A. Johnson wrote:
>> I need to fill the [] with a number. I had wanted to write a shell script
>> to do that. I have googled for 2 days and have yet to discover how
>> to increment a numerical variable in 'sed'.
>
> Use awk, not sed, e.g.:
>
> awk 'BEGIN { n = 1 }
> { while ( sub(/[[][]]/,"[" n "]" ) ) ++n ; print }
> ' FILENAME > NEWFILE
Thanks Chris.............
Worked beautifully.
--
A little rum in the morning coffee. Just to clear the cobwebs, ya know.
[Back to original message]
|