what is wrong with this code? i want to search the strings "fail" and "09x83377" from all entries. im grabbing all entries in the log starting from Jan 5 04:33 to the end of the file.
what is wrong with this code? i want to search the strings "fail" and "09x83377" from all entries. im grabbing all entries in the log starting from Jan 5 04:33 to the end of the file.
Hello Skysmart,
Could you please let us know if these strings which you are searching for are in a single line or multiple lines(Which I think may bein single line only), also if you can provide us your os details with Input data it will be helpful for us to guide/advise.
EDIT: Seems you have added some information now , let's try the following command (Not tested though) for same and
let me know if this helps. NOTE: Make sure you are searching correct string Jan 5 04:33 with proper spaces in it.
Thanks,
R. Singh
Last edited by RavinderSingh13; 01-06-2015 at 06:20 AM..
Reason: Added solution as user added comments for input
This User Gave Thanks to RavinderSingh13 For This Post:
Hi SkySmart,
The standards describe a pattern (in an awk command) as:
Quote:
A pattern is any valid expression, a range specified by two expressions separated by a comma, or
one of the two special patterns BEGIN or END.
In the awk command:
You have a range that is specified by the two expressions: /^Jan 5 04:33/ and 0 && /fail/ && /09x83377/
The zero in the 2nd expression guarantees that that expression will evaluate to false for every line; so the range starts on the 1st line that matches the extended regular expression specified by the 1st expression and continues to the end of the input file(s). The standards don't provide any way to include both a range and another expression in the same pattern. (In other words, the meaning of:
is not defined to have any meaning in conforming awk utilities. Of course, gawk provides several extensions to the standards. But I don't know of any version of awk that supports this type of pattern as an extension to the standards.)
Hopefully, this explains what is wrong with your gawk script.
If what you want is to select and count the set of lines that contain both the string fail and the string 09x83377 on or after the 1st line that contains Jan 5 04:33 at the start of a line, Ravinder's suggestion should be enough for you to fix your problem. If that isn't what you want, please explain more clearly which lines you are trying to count. (And provide some sample input for us to use to test possible scripts.)
This User Gave Thanks to Don Cragun For This Post:
How to write in awk to remove lines starting with "#" and then process the file:
This is not working:
cat file|awk '{if ($0 ~ /^#/) $0="";print NF>0}'
When I just give cat file|awk '{if ($0 ~ /^#/) $0="";print }'
it prints the blank lines . I don't wnat the blank lines along with the... (15 Replies)
Hi Guru's.
I am trying to use to check if $5 is greater than 80 & if not 100, then to print $0 :
awk '{ if ($5>80) && if ($5 != 100) print $0}
But getting error:
>bdf1|sed 's/%//g'|awk '{ if ($5>80) && if ($5 != 100) print $0}'
syntax error The source line is 1.
The error... (6 Replies)
Hi fellow linux-ers,
I have a quick question for you. I have the following text, which I would like to modify:
10 121E(121) 16 Jan
34S 132E 24 Feb
42 176E(176) 18 Sep
21S 164E 25 May
15 171W(-171) 09 Jul
How can I do the following 2 modifications using sed and/or awk?
1. in 1st column,... (1 Reply)
When I have a file like this:
0084AF aj-123-a NAME Ajay NAME Kumar Engineer
015ED6 ck-345-c
020B25 ef-456-e
027458 pq-890-p NAME Peter NAME Salob Doctor
0318F0 xy-123-x NAME Xavier Arul NAME Yesu Supervisor
0344CA de-456-d
where - The first NAME is followed by... (6 Replies)
I am using sed to find a pattern in a line and then I want to retain the pattern + the rest of the line. How is this possible? ie:
line is: 14158 05-15-08 20:00 123-1234-A21/deliverable/dhm.a
search for 123-1234-A21 ie:
echo $line | sed 's/.*\(\{3\}-\{4\}-\{3\}\{5\}\).*/\1/'
... (1 Reply)
Ok. I'm just starting to use AWK and I have a question. Here's what I'm trying to do:
uname -n returns the following on my box:
ftsdt-svsi20.si.sandbox.com
I want to pipe this to an AWK statement and make it only print:
svsi20
I tried:
uname -n | awk '{ FS = "." ; print $1 }'
... (5 Replies)
Hi, I am new to UNIX, and am learning from this tutorial : http://www.ee.surrey.ac.uk/Teaching/Unix/index.html
It keeps telling me to files downloaded from the internet (like .txt files) to the directory, and I dont know how to.
How do I add .txt files to my directory? Thanks. (6 Replies)
Hello There!
I am trying to write this SIMPLE script in Bourne Shell but I keep on getting syntax errors. Can you see what I am doing wrong? I've done this before but I don't see the difference. I am simply trying to take the day of the week from our system and when the teachers sign on I want... (7 Replies)