I am new to Unix and currently I have a large file of various data. In this file there are lines that are now redundant and will need to be removed.
In the file the pattern:
<contact contact_id="<number>" txn="D">
</contact>
Edit: There are also similar lines to the ones to be removed, an example is:
<contact contact_id="<number>" txn="N">
</contact>
I have attempted to use grep -A 1
to pick up the pattern and remove the next line however I am operating on an old version of Solaris and -A is an illegal expression.
As well as this I have attempted to use sed -e '12442,+1d'
and this just give the ouput of
sed: command garbled: 12442,+1d
.
Please can you help me with a new solution.
use awk?
something like
/<contact contact_id=.* txn="D">/ { got_contact = 1; next }
got_contact == 1 { got_contact = 0; next }
{ print }
even the ancient awk should be able to handle that. (There might be a more compact solution, but this isn't code golf)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments