[Nottingham] Slow bash-ings for file line search

Peter Chang Peter.Chang at nottingham.ac.uk
Tue Apr 5 23:22:26 BST 2005


Martin,

On Tue, 5 Apr 2005, Martin wrote:

> Martin Garton wrote:
> > 
> > What's wrong with sed or awk for this? (or even perl)
> > 
> > Are you doing something more complicated than e.g. sed can do once the
> > lines are identified?
> 
> Yes, just slightly.
> 
> This started as a very quick hack to add tags into some MS-generated 
> html mess where the "name=" is to be inserted a few lines _before_ a 
> change of day is noticed later in the text.

[snipped]

>          if [ "$id" -ge "0" ]

I don't understand this line. You start with id=0 and increment it so this
test is always true.

The best way for doing this in awk is to go through the file and store
lines that are between those markers and then on a transition point, spit
out your tag and the stored lines.

Peter



This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.




More information about the Nottingham mailing list