- Original Message -
From: "Dotan Cohen"
To: "CentOS mailing list"
Sent: Tuesday, June 7, 2011 1:20:20 AM
Subject: Re: [CentOS] Grep: show me this line and the next N lines?
On Tue, Jun 7, 2011 at 05:26, Kenneth Porter wrote:
> --On Tuesday, May 31, 2011 1:
On Tue, Jun 7, 2011 at 05:26, Kenneth Porter wrote:
> --On Tuesday, May 31, 2011 1:08 AM +0300 Dotan Cohen
> wrote:
>
>> Can grep show the matching lines and the next N lines after a match?
>
> If I'm just inspecting a file I use less and the "/" command to search up
> to the next occurrence of a
--On Tuesday, May 31, 2011 1:08 AM +0300 Dotan Cohen
wrote:
> Can grep show the matching lines and the next N lines after a match?
If I'm just inspecting a file I use less and the "/" command to search up
to the next occurrence of a regular expression. Use the "?" command to
search backwards.
On 5/31/2011 3:43 AM, Dotan Cohen wrote:
> On Tue, May 31, 2011 at 01:26, John R. Dennison wrote:
>> On Tue, May 31, 2011 at 01:10:40AM +0300, Dotan Cohen wrote:
>>> Thanks, all. I did actually look at the grep manpage but after a few
>>> screenfuls it became tl;dr and I started just skimming.
On Tue, May 31, 2011 at 01:26, John R. Dennison wrote:
> On Tue, May 31, 2011 at 01:10:40AM +0300, Dotan Cohen wrote:
>> Thanks, all. I did actually look at the grep manpage but after a few
>> screenfuls it became tl;dr and I started just skimming. I suppose that
>> I skimmed too fast!
>
> Um
On Tue, May 31, 2011 at 01:10:40AM +0300, Dotan Cohen wrote:
> Thanks, all. I did actually look at the grep manpage but after a few
> screenfuls it became tl;dr and I started just skimming. I suppose that
> I skimmed too fast!
Um
It's the first option described.
Thanks, all. I did actually look at the grep manpage but after a few
screenfuls it became tl;dr and I started just skimming. I suppose that
I skimmed too fast!
Thanks!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
___
CentOS mailing li
On Tue, May 31, 2011 at 12:08:37AM +0300, Dotan Cohen wrote:
>
> Can this be done?
"man grep" - I think you will be surprised when you take a look at it.
John
--
Worrying works. About 90% of the things I worry about never happen.
-- W
On Mon, May 30, 2011 at 5:08 PM, Dotan Cohen wrote:
> Can grep show the matching lines and the next N lines after a match?
>
> I would ideally grep on "[Tag h1]" and have grep display the match and
> the next 5 lines so that I see all the content of the h1 section.
>
Try
grep -A 5 pattern fil
Dotan Cohen wrote:
> Can grep show the matching lines and the next N lines after a match?
> For instance, I have a config file wit hthe following text:
> [Tag h1]
> foreground=#2e5a03
> underline=double
> indent=0
> weight=PANGO_WEIGHT_BOLD
> scale=2.25
>
> I would ideally grep on "[Tag h1]" and h
On 05/30/2011 11:08 PM, Dotan Cohen wrote:
> Can grep show the matching lines and the next N lines after a match?
> For instance, I have a config file wit hthe following text:
> [Tag h1]
> foreground=#2e5a03
> underline=double
> indent=0
> weight=PANGO_WEIGHT_BOLD
> scale=2.25
>
> I would ideally
Can grep show the matching lines and the next N lines after a match?
For instance, I have a config file wit hthe following text:
[Tag h1]
foreground=#2e5a03
underline=double
indent=0
weight=PANGO_WEIGHT_BOLD
scale=2.25
I would ideally grep on "[Tag h1]" and have grep display the match and
the next
At Fri, 15 Oct 2010 12:11:17 +0200 CentOS mailing list
wrote:
>
> Hi folks
>
> I have the command "find . | xargs grep 'mailx'", to search all files
> with "mailx" in contents. I wish to add a second condition that NOT
> contains string sven.alu...@ubs.com on the same line.
>
> Every file whi
Hi folks
I have the command "find . | xargs grep 'mailx'", to search all files
with "mailx" in contents. I wish to add a second condition that NOT
contains string sven.alu...@ubs.com on the same line.
Every file which contains "mailx", but not the string
sven.alu...@ubs.com in the same line.
che
At Fri, 24 Sep 2010 13:50:11 -0400 CentOS mailing list
wrote:
>
> Hello,
>
> I am attempting to grep the contents of a key file I have SCP'd to a
> remote server. I am able to cat it:
>
> [code]
> [bluethu...@lbsd2:~]$:ssh r...@sum1 cat /root/id_rsa.pub
> r...@lcent01.summitnjhome.com's pass
On 9/24/2010 12:50 PM, Tim Dunphy wrote:
> Hello,
>
> I am attempting to grep the contents of a key file I have SCP'd to a
> remote server. I am able to cat it:
>
> [code]
> [bluethu...@lbsd2:~]$:ssh r...@sum1 grep `cat /root/id_rsa.pub`
Put single quotes around the whole command you want to sen
Hello,
I am attempting to grep the contents of a key file I have SCP'd to a
remote server. I am able to cat it:
[code]
[bluethu...@lbsd2:~]$:ssh r...@sum1 cat /root/id_rsa.pub
r...@lcent01.summitnjhome.com's password:
ssh-rsa
B3NzaC1yc2EBIwAAAQEApnUSYyrM96qIBZKjwSNYycgeSv/FAKE-KEY-DATA-
Tony Schreiner wrote:
> On Jun 10, 2009, at 2:18 PM, Joseph L. Casale wrote:
>
>> I am rsyncing and remotely doing some work based on a logfile from
>> a windows box from a centos backup server. I get the output from a
>> vss snapshot that has a section like this:
>>
>> * SNAPSHOT ID = {639ef5df-c
On Jun 10, 2009, at 2:18 PM, Joseph L. Casale wrote:
> I am rsyncing and remotely doing some work based on a logfile from
> a windows box from a centos backup server. I get the output from a
> vss snapshot that has a section like this:
>
> * SNAPSHOT ID = {639ef5df-c933-4496-878a-ed57b9d52876} ..
>If the line counts are constant you could do the reverse:
>
>grep -B 3 "\(E:\|D:\)" input.txt | grep Shadow
Now that's cool, each case has to be separate so
grep -B 3 "D:" input.txt or even the actual volume string for
certainties sake is the ticket!
Thanks Nate and Bill!
jlc
__
On Wed, 2009-06-10 at 12:01 -0700, nate wrote:
> Joseph L. Casale wrote:
>
> > if the text indented beneath it has "D:", then do the same and extract
> > "SNAPSHOT ID" if and only if "E:" follows?
>
> If the line counts are constant you could do the reverse:
>
> grep -B 3 "\(E:\|D:\)" input.txt
Joseph L. Casale wrote:
> if the text indented beneath it has "D:", then do the same and extract
> "SNAPSHOT ID" if and only if "E:" follows?
If the line counts are constant you could do the reverse:
grep -B 3 "\(E:\|D:\)" input.txt | grep Shadow
Which would show the 3 lines above a line that
On Wed, 2009-06-10 at 18:18 +, Joseph L. Casale wrote:
> I am rsyncing and remotely doing some work based on a logfile from
> a windows box from a centos backup server. I get the output from a
> vss snapshot that has a section like this:
>
> * SNAPSHOT ID = {639ef5df-c933-4496-878a-ed57b9d528
I am rsyncing and remotely doing some work based on a logfile from
a windows box from a centos backup server. I get the output from a
vss snapshot that has a section like this:
* SNAPSHOT ID = {639ef5df-c933-4496-878a-ed57b9d52876} ...
- Shadow copy Set: {427ac5db-21be-4c53-8ca4-24e7bac86a1d}
On Tue, 2007-08-28 at 23:30 -0400, Stephen Harris wrote:
> On Tue, Aug 28, 2007 at 05:04:33PM -0500, Les Mikesell wrote:
>
> >
> I'm probably fighting a losing battle; I was shell scripting 17 years
> ago when every fork/exec was expensive. I cry when I see people writing
> grep | awk
> type
On Tue, 2007-08-28 at 10:05 -0400, Scott McClanahan wrote:
> Not a CentOS specific question, although I am running grep on CentOS 4.3
> but how would you grep out a series of lines in a file starting at a
> specific point. For instance, if I have a file named foo and I want to
> grep out the next
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Wed, Aug 29, 2007 at 11:54:42AM +0800, Ming wrote:
> I got the have install a SATA HardDisk on the machine recently. But somethings
> the Disk cannot be accessed. And mesg tells that it is IO error. Is it a
> hardware problem or system setting probl
Old geek statement: If you think perl is the answer to a simple filter
question then think twice. You might be right, but it's likely smaller
faster tools already exist. And I say this as someone who has written
1000 line shell scripts and even bigger perl scripts; perl is good for
complicated
Let's try to not hijack threads on the mailing list please.
On 8/28/07, Ming <[EMAIL PROTECTED]> wrote:
> I got the have install a SATA HardDisk on the machine recently. But
> somethings the Disk cannot be accessed. And mesg tells that it is IO error.
> Is it a hardware problem or system setting p
Stephen Harris wrote:
> In this case, everyone who responded with a perl solution needs their
> hammer taken away.
LET GO OF MY HAMMER NOW!
Cheers,
Ralph
pgpyk5rETOQZ1.pgp
Description: PGP signature
___
CentOS mailing list
CentOS@centos.org
http://li
Ming wrote:
I got the have install a SATA HardDisk on the machine recently. But
somethings the Disk cannot be accessed. And mesg tells that it is IO
error. Is it a hardware problem or system setting problem.
Here is the message from dmesg.
sd 0:0:0:0: SCSI error: return code = 0x0004
I got the have install a SATA HardDisk on the machine recently. But
somethings the Disk cannot be accessed. And mesg tells that it is IO error.
Is it a hardware problem or system setting problem.
Here is the message from dmesg.
sd 0:0:0:0: SCSI error: return code = 0x0004
> end_request: I/O e
On Tue, Aug 28, 2007 at 05:04:33PM -0500, Les Mikesell wrote:
> It's easy to hate perl that other people have written, but you can write
> your own in whatever style you like.
6 years ago I wrote a perl regexp that did some magic. The comment before
it...
# It's lines like this that make peop
Rodrigo Barbosa wrote:
On Tue, Aug 28, 2007 at 10:31:08AM -0400, Scott McClanahan wrote:
On Tue, 2007-08-28 at 10:27 -0400, Stephen Harris wrote:
$ sed '/bar/,+5d' xx
line 1
line 2
line after 6
line after 7
Beautiful man! Hats off. I've never used sed like that but I'll surely
reme
Rodrigo Barbosa wrote:
>
> Ick. I hate perl.
>
> If I find something I can't do in bash/sed/awk, I just code it in C :)
Ick. I hate C. ;)
If I can't use grep, I'll use an short inline Perl script. Or, in
extreme cases, I'll write a small utility script. Or, more commonly,
I'll write a huge
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Tue, Aug 28, 2007 at 12:17:01PM -0500, Les Mikesell wrote:
> Rodrigo Barbosa wrote:
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA1
> > On Tue, Aug 28, 2007 at 10:31:08AM -0400, Scott McClanahan wrote:
> >> On Tue, 2007-08-28 at 10:27 -0400,
Rodrigo Barbosa wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Tue, Aug 28, 2007 at 10:31:08AM -0400, Scott McClanahan wrote:
On Tue, 2007-08-28 at 10:27 -0400, Stephen Harris wrote:
$ sed '/bar/,+5d' xx
line 1
line 2
line after 6
line after 7
Beautiful man! Hats off. I've
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Tue, Aug 28, 2007 at 12:12:52PM -0400, Jim Perrin wrote:
> On 8/28/07, Rodrigo Barbosa <[EMAIL PROTECTED]> wrote:
>
> EDITED:
> > Mastering sed is a bit like mastering Latin. backwards.
>
> There. Fixed that for you. :-P
I see you enjoyed my
On 8/28/07, Rodrigo Barbosa <[EMAIL PROTECTED]> wrote:
EDITED:
> Mastering sed is a bit like mastering Latin. backwards.
There. Fixed that for you. :-P
--
During times of universal deceit, telling the truth becomes a revolutionary act.
George Orwell
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Tue, Aug 28, 2007 at 10:31:08AM -0400, Scott McClanahan wrote:
> On Tue, 2007-08-28 at 10:27 -0400, Stephen Harris wrote:
> > $ sed '/bar/,+5d' xx
> > line 1
> > line 2
> > line after 6
> > line after 7
> >
> Beautiful man! Hats off. I've
On Tue, 2007-08-28 at 10:27 -0400, Stephen Harris wrote:
> On Tue, Aug 28, 2007 at 10:13:00AM -0400, Scott McClanahan wrote:
> > On Tue, 2007-08-28 at 10:08 -0400, Stephen Harris wrote:
> > > > Not a CentOS specific question, although I am running grep on CentOS 4.3
> > > > but how would you grep o
Scott McClanahan wrote:
I'd like to skip those lines. I'd like to skip the line with "bar" and
the following five lines.
In that case, the perl code would be:
#!/usr/bin/perl
$eat = 0;
while (<>) {
if (m/bar/) {
$eat = 6;
}
if ($eat) {
--$eat;
}
else {
On Tue, Aug 28, 2007 at 10:13:00AM -0400, Scott McClanahan wrote:
> On Tue, 2007-08-28 at 10:08 -0400, Stephen Harris wrote:
> > > Not a CentOS specific question, although I am running grep on CentOS 4.3
> > > but how would you grep out a series of lines in a file starting at a
> > > specific point
Scott McClanahan wrote:
grep out the next 5 lines after the first and only instance
The scope of grep's view of the world is a single line. At any one
time, it knows nothing more.
If you need to deal with multiple lines, I suggest perl. Untested code:
#!/usr/bin/perl
while (<>) {
>
> Not a CentOS specific question, although I am running grep on
> CentOS 4.3
> but how would you grep out a series of lines in a file starting at a
> specific point. For instance, if I have a file named foo and
> I want to
> grep out the next 5 lines after the first and only instance of the
>
On Aug 28, 2007, at 10:05 AM, Scott McClanahan wrote:
Not a CentOS specific question, although I am running grep on
CentOS 4.3
but how would you grep out a series of lines in a file starting at a
specific point. For instance, if I have a file named foo and I
want to
grep out the next 5 li
On Tue, 2007-08-28 at 10:08 -0400, Stephen Harris wrote:
> > Not a CentOS specific question, although I am running grep on CentOS 4.3
> > but how would you grep out a series of lines in a file starting at a
> > specific point. For instance, if I have a file named foo and I want to
> > grep out the
On 8/28/07, Scott McClanahan <[EMAIL PROTECTED]> wrote:
> Not a CentOS specific question, although I am running grep on CentOS 4.3
> but how would you grep out a series of lines in a file starting at a
> specific point. For instance, if I have a file named foo and I want to
> grep out the next 5 l
> Not a CentOS specific question, although I am running grep on CentOS 4.3
> but how would you grep out a series of lines in a file starting at a
> specific point. For instance, if I have a file named foo and I want to
> grep out the next 5 lines after the first and only instance of the
> string "
Not a CentOS specific question, although I am running grep on CentOS 4.3
but how would you grep out a series of lines in a file starting at a
specific point. For instance, if I have a file named foo and I want to
grep out the next 5 lines after the first and only instance of the
string "bar" how c
50 matches
Mail list logo