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

incremental numbering

Status
Not open for further replies.

Pugman

MIS
Aug 24, 2001
27
US
I have a problem where I need to search for "/BM /View" within a postscript file and then incrementally number each "/BM" so that the result would be like "/BM1 /View", "/BM2 /View", etc.

I have tried nl to accomplish this, but nl will corrupt any postscript file that has a photograph in it.

Please help!
 
How many numbers do you have to do? For example:

FCOUNT=$(HOWEVER HIGH THE BM NUMBERS GO) #Final Count

for REGEXP in ${FILES} # where FILE is what has the BM in it
do
COUNT=1
while [ ${COUNT} -ne ${FCOUNT} ]
do
grep BM${COUNT} ${REGEXP}

....commands....

let COUNT=COUNT+1
done
done


I think this is what you want to do, maybe a bit to complicated for what you need, but then I'm not quite sure on what you are doing exactly. Hope it works.
 
Thanks pmcmicha for your advice, but I couldn't get it to work.

I ended up using Perl to do what I needed:

perl -pi -e 's#(^\[/Dest /BM)\d+(\s+/View)# $1 . ++$count . $2#e' $file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top