I want to find a pattern. Then I want to compare string 4 of the line with the pattern in it to string 4 of the line above it. If those 2 strings match, I want to delete both lines.
I know this will delete line with pattern and line above but I don't know how to add the step of matching up...
I am using a sed statement to print every nth line. In the example below, I am printing every 15th line starting at line 15.
What if I want to print every 150th line? Is there a way in awk or sed to not have to type out all the n's? It would not be practical to type 149 n's.
sed -n...
sed '/FRM CHK 000000/{n;d;}’ filename
I have tried this. It gets rid of the line after my pattern. I still need to get rid of the line before my pattern and the line with my pattern.
awk '/FRM CHK 000000/ { print last; print; x = 1; next }
x == 1 { print; x = 0 }
{ last = $0 }
' filename
Somebody gave me this. It prints out the lines I am trying to delete. I need to change their code so it deletes those lines instead of printing them.
I have a file that will sometimes contain a pattern. The pattern is this:
FRM CHK 000000
I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below.
I have an awk script that is getting me part of what I need. It is giving me the lines with the criteria I have specified.
{
if (($3 == 0) || (($9 == 304) || ($9 == 306)))
{ print $0 }
}
Here is what else I need to do but don't know how. In the
(($3==0) part, I ALSO need the line...
Is there a unix equivalent to :beginfile and :endfile
For example, I am doing some editing with qedit. I want everything that is output from the qedit program to end up in a file. We are using HPUX (and this script would be run inside of a batch script and not manually) so it would look...
I have 2 files. In some of the records, string 1 will match but other strings will not. I want to be able to report out the records from file 2 where string 1 matches string 1 from file 1.
Ex.
FILE 1
111
222
333
444
555
FILE 2
111 AAAA
345 DKDK
4445 45TG
444 BBB
In this...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.