All Questions
1,090
questions
3
votes
3
answers
4k
views
Show lines matching a pattern and the 4 lines before each
For example, from this file:
CREATE SYNONYM I801XS07 FOR I8010.I801XT07
*
ERROR at line 1:
ORA-00955: name is already used by an existing object
CREATE SYNONYM I801XS07 FOR I8010....
-1
votes
1
answer
5k
views
Sum of grep results
I need to output the sum of a grep results for a certain time, for now i hard coded the time grep but any help will be very much appreciated, my problem is i cant output the results on the script.
If ...
3
votes
1
answer
4k
views
Time/Date grep for 15 mins
I need to grep a specific type of line in a specific time of the log, do you have any ideas?
Here's my working script:
cat *.log |grep -E '2011-06-30 (1[0-1]:[0-1][0-5]|10:16)'| grep -ach '0110 ...
2
votes
3
answers
2k
views
pad a number with zeroes
I need have put 0 on the results of my grep so my script format will be fine and i don't have any idea how to do it. here's my grep result :
261 : 261 = 0 | 1192 : 1184 = 8 |
283 : 283 = 0 | 666 : ...
10
votes
6
answers
4k
views
Is there any alternative to grep's -A -B -C switches (to print few lines before and after )?
grep -A 2 -B 3
prints 2 lines after the grep string and prints 3 lines before.
grep -C 3
prints 3 Lines before and 3 lines after
Unfortunately, the grep I'm using does not support these options. ...
33
votes
5
answers
85k
views
Multiline pattern match using sed, awk or grep [duplicate]
Is it possible to do a multiline pattern match using sed, awk or grep? Take for example, I would like to get all the lines between { and }
So it should be able to match
1. {}
2. {.....}
3. {........
6
votes
3
answers
20k
views
Extracting tokens from a line of text [closed]
Using bash scripting and grep/awk/sed, how can I split a line matching a known pattern with a single character delimiter into an array, e.g. convert token1;token2;token3;token4 into a[0] = token1 … ...
4
votes
2
answers
2k
views
Using grep/sed/awk to classify log file entries
I need to process a very large log file with many lines in different formats.
My goal is to extract unique line entries who have the same starting pattern, e.g. '^2011-02-21.*MyKeyword.*Error', ...
3
votes
1
answer
16k
views
Filtering on dates with grep and awk
I have created the alias below in my .bash_aliases file
alias auth="grep \"$(date|awk '{print $2,$3}')\" /var/log/auth.log |
grep -E '(BREAK-IN|Invalid user|Failed|refused|su|Illegal)'"
...
112
votes
7
answers
73k
views
Is there a basic tutorial for grep, awk and sed? [closed]
I've been a Linux user for a while, and I've a pretty decent understanding of most the common command line utilities. However, ones that come up and up again in relation to programming are grep, awk, ...