Ok so I can use awk to match a pattern and print the whole line with print $0. Is there any way to just tell awk to print every line of output when the pattern matches?
I'm having it wait for the word error and then print that entire line. But what I actually need to see is all the following lines after the line with the error. So there has got to be some easy way to just tell awk to print everything when there is a pattern match?
I'm having it wait for the word error and then print that entire line. But what I actually need to see is all the following lines after the line with the error.
does it mean, you want all lines that after the line which match word "error" the very first time?
like
what you are looking for are lines ( 3- 100) ?
I'll have to try this when I get back into work again. But, basically I'm looping a simple command and I only want to see output when it errors. The rest of the time I don't care and don't want to see anything.
The commands output is either going to be OK or error followed by lines of information about the error and why it occured. Could be 3 lines could be 10 you never know. But I need to leave this running for hours and hours. I didn't want to see 10,000 lines of this
OK
OK
OK
OK
OK
OK
Error
OK
OK
So I am just doing the simple awk command so that it only prints the line when it actually fails and gives me an error. My only issue at this point is that I get the Error line but none of the follow up lines. So at least I know when it fails but, I have no details on why.
There is no input file its a simple command and the results of the command are my input. There is no way to know what the output will be when the error occurs nor how many lines. I can presume it would be no more than say 10 lines at most. That's why I was hoping I could just find some way to say. If you see this word then print all output that can be printed.
---------- Post updated at 09:06 PM ---------- Previous update was at 05:54 PM ----------
Well I did this and it is partially successful. It does print the lines after the match. However it doesn't print the original line with the error on it. Thats not critical and I could live without it. Would be cleaner if the original error line printed also.
However the pattern match doesn't seem to work as my original command did. It runs subsequent date command every time it runs the command regardless of a match to the pattern.
I wind up getting this as my output when the output is OK. Ideally I only want to see any output when it fails. So I gotta figure out how to get the Date command to only execute when the pattern matches.
In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Hello,
I have a file contains two columns. I need to print the lines after “xxx” so i'm trying to match "xxx" & cut the lines after that. I'm trying with the grep & cut command, if there any simple way to extract this please help me.
Sample file :
name id
AAA 123
AAB 124
AAC 125... (4 Replies)
URGENT HELP IS NEEDED!!
I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but
- Currently, script is not printing lines to File3.txt in order.
- Also the matching lines are not moving out of File1.txt
... (1 Reply)
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
Data:
Pattern Data Data Data
Data Data Data
Data Data Data
...
With awk, how do I print the pattern matching line, then the subsequent lines following the pattern matching line. Varying number of lines following the pattern matching line. (9 Replies)
Hi, I have this file.
close
block3c
block3b
block3a
open
close
block2b
block2a
open
close
block1a
open
and I need :
open
block3a
block3b
block3c
close (1 Reply)
Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file.
For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt
I tried with grep -A but it's not supported on my system.
I tried with awk,... (4 Replies)
I am using Solaris, I want to print
3 lines before pattern match
pattern
5 lines after pattern match
Pattern is abcd to be searched in a.txt. Looking for the solution in sed/awk/perl. Thanks ..
Input File a.txt:
=================
1
2
3
abcd
4
5
6
7
8 (7 Replies)
I am trying to parse iostat output for io issues..
I want to print all lines including second occurance of 'extended' till EOF(end of file). Can we do that using awk or sed one liners or do we need a script for it? (1 Reply)
Hi folks,
I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)