Re: [CentOS] Grep: show me this line and the next N lines?

2011-06-07 Thread Jon Detert
- 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:

Re: [CentOS] Grep: show me this line and the next N lines?

2011-06-06 Thread Dotan Cohen
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

Re: [CentOS] Grep: show me this line and the next N lines?

2011-06-06 Thread Kenneth Porter
--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.

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-31 Thread Thomas Harold
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.

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-31 Thread Dotan Cohen
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

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-30 Thread John R. Dennison
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.

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-30 Thread Dotan Cohen
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

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-30 Thread John R. Dennison
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

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-30 Thread Meenoo Shivdasani
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

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-30 Thread Ljubomir Ljubojevic
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

Re: [CentOS] Grep: show me this line and the next N lines?

2011-05-30 Thread Pintér Tibor
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

[CentOS] Grep: show me this line and the next N lines?

2011-05-30 Thread Dotan Cohen
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

Re: [CentOS] grep pattern x, but not pattern y on the same line

2010-10-15 Thread Robert Heller
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

[CentOS] grep pattern x, but not pattern y on the same line

2010-10-15 Thread Sven Aluoor
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

Re: [CentOS] grep contents of file on remote server

2010-09-24 Thread Robert Heller
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

Re: [CentOS] grep contents of file on remote server

2010-09-24 Thread Les Mikesell
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

[CentOS] grep contents of file on remote server

2010-09-24 Thread Tim Dunphy
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-

Re: [CentOS] grep/sed help

2009-06-10 Thread Les Mikesell
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

Re: [CentOS] grep/sed help

2009-06-10 Thread Tony Schreiner
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} ..

Re: [CentOS] grep/sed help

2009-06-10 Thread Joseph L. Casale
>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 __

Re: [CentOS] grep/sed help

2009-06-10 Thread William L. Maltby
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

Re: [CentOS] grep/sed help

2009-06-10 Thread nate
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

Re: [CentOS] grep/sed help

2009-06-10 Thread William L. Maltby
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

[CentOS] grep/sed help

2009-06-10 Thread Joseph L. Casale
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}

Re: [CentOS] grep

2007-09-03 Thread William L. Maltby
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

Re: [CentOS] grep

2007-09-03 Thread William L. Maltby
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

Re: [CentOS] grep

2007-08-29 Thread Rodrigo Barbosa
-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

Re: [CentOS] grep

2007-08-29 Thread Feizhou
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

Re: [CentOS] grep

2007-08-29 Thread Jim Perrin
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

Re: [CentOS] grep

2007-08-29 Thread Ralph Angenendt
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

Re: [CentOS] grep

2007-08-28 Thread John R Pierce
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

Re: [CentOS] grep

2007-08-28 Thread Ming
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

Re: [CentOS] grep

2007-08-28 Thread Stephen Harris
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

Re: [CentOS] grep

2007-08-28 Thread Les Mikesell
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

RE: [CentOS] grep

2007-08-28 Thread Bowie Bailey
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

Re: [CentOS] grep

2007-08-28 Thread Rodrigo Barbosa
-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,

Re: [CentOS] grep

2007-08-28 Thread Les Mikesell
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

Re: [CentOS] grep

2007-08-28 Thread Rodrigo Barbosa
-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

Re: [CentOS] grep

2007-08-28 Thread Jim Perrin
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

Re: [CentOS] grep

2007-08-28 Thread Rodrigo Barbosa
-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

Re: [CentOS] grep

2007-08-28 Thread Scott McClanahan
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

Re: [CentOS] grep

2007-08-28 Thread Warren Young
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 {

Re: [CentOS] grep

2007-08-28 Thread Stephen Harris
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

Re: [CentOS] grep

2007-08-28 Thread Warren Young
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 (<>) {

RE: [CentOS] grep

2007-08-28 Thread mike.redan
> > 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 >

Re: [CentOS] grep

2007-08-28 Thread Steve Huff
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

Re: [CentOS] grep

2007-08-28 Thread Scott McClanahan
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

Re: [CentOS] grep

2007-08-28 Thread Jim Perrin
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

Re: [CentOS] grep

2007-08-28 Thread Stephen Harris
> 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 "

[CentOS] grep

2007-08-28 Thread Scott McClanahan
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