[wellylug] Is there a good way to....
Tony Booth
Tony.Booth at treasury.govt.nz
Thu Jan 29 18:21:23 NZDT 2004
Oops. It should probably be:
sed -e '/RE/!s/(.*)/\1/g' filename
Note the changed position of the exlamation mark. I still can't
guarantee it will work though!
If you can let us know what string you need to match, I'm sure someone
can give you the RE part explicitly.
TB
Enkidu wrote:
> Is there a good way to drop lines from a file or do I have to do
> something like
> (pseudo-code) ....
>
> Open Output
> Open Input
> Read While Input
> If Record is a Match
> Then Write Output
> Else Nothing
> End Read
> Close Input
> Close Output
>
> Cheers,
Well, I only have access to a Windows machine right now, so I haven't
tested this, but you could try:
sed -e '/RE!/s/(.*)/\1/g' filename
Where:
* RE is a regular expression to match (as in your 'Record is a Match'
pseudo-code)
* The exclamation mark _should_ negate the RE, so that only lines not
matching are picked up. This isn't totally clear from the
documentation, but I hope it will work.
* (.*) is the line from the file (you might need backslashes before each
bracket)
* \1 means to replace the line with the the (.*) text (i.e. take the
whole line and just print it out)
Best of luck.
More information about the wellylug
mailing list