Re: extract all text lines between 2 lines in a file?
Tom Buskey wrote: I have a file: You don't say :) ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract all text lines between 2 lines in a file?
On Wed, 2004-04-07 at 14:31, Tom Buskey wrote: I have a file: Would you care to share the file with us? Or are you just bragging because you have a file? ;-) C-Ya, Kenny signature.asc Description: This is a digitally signed message part
Re: extract all text lines between 2 lines in a file?
Here's one approach: sed -e '/^uniqdelimiter$/,/^uniqdelimiter$/p' -e d | sed -e 1d -e '$d' ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract all text lines between 2 lines in a file?
I have a file: Would you care to share the file with us? Or are you just bragging because you have a file? ;-) It's marked TOP SECRET so I guess I can't... Sorry ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract all text lines between 2 lines in a file?
perl -e 'open (JUNK, junk); while (JUNK) { if (/uniqdelimiter/) { if ($value) { $value = 0; } else { $value = 1; } } (print $_) if $value; } }' or.. in a script: #!/usr/bin/perl -w use strict; my $file = $ARGV[0]; my $value = 0; open(FILE, $file); while (FILE) { if (/uniqdelimiter/) { if ($value) { $value = 0; } else { $value = 1; } } (print $_) if $value; } On Wed, 7 Apr 2004, Tom Buskey wrote: Oops, sorry about last post I have a file: #!/bin/sh command1 command2 uniqdelimiter command3 command4 uniqdelimiter command5 I want to filter it and get: command3 command4 In other words, everything between the lines that say uniqdelimter. This will do it: sed '0,/^uniqdelimiter/d' file | sed '/^uniqdelimter/d' but I'd like a one liner in sed, grep or awk. I'll settle for perl too :-) ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss -- Citation : The number of UNIX installations has grown to 10, with more expected. _The UNIX Programmer's Manual_, Second Edition, June, 1972 ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract all text lines between 2 lines in a file?
Oops, sorry about last post I have a file: Haha on the comments ;-) /me blames using squirrelmail and hitting tab then return #!/bin/sh command1 command2 uniqdelimiter command3 command4 uniqdelimiter command5 I want to filter it and get: command3 command4 In other words, everything between the lines that say uniqdelimter. This will do it: sed '0,/^uniqdelimiter/d' file | sed '/^uniqdelimter/d' but I'd like a one liner in sed, grep or awk. I'll settle for perl too :-) I answered my own question: sed '0,/^uniqdelimiter/d' -e '/^uniqdelimter/d' file ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract all text lines between 2 lines in a file?
On Wed, Apr 07, 2004 at 03:05:52PM -0400, Tom Buskey [EMAIL PROTECTED] wrote: #!/bin/sh command1 command2 uniqdelimiter command3 command4 uniqdelimiter command5 I want to filter it and get: command3 command4 In other words, everything between the lines that say uniqdelimter. This will do it: sed '0,/^uniqdelimiter/d' file | sed '/^uniqdelimter/d' but I'd like a one liner in sed, grep or awk. I'll settle for perl too :-) I answered my own question: sed '0,/^uniqdelimiter/d' -e '/^uniqdelimter/d' file Odd, doesn't seem to be working for me. FWIW, a Perl solution: perl -ne 'print if $m==1 and not /^uniqdelimiter/;$m+=/^uniqdelimiter/;' file -- Bob Bell ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract all text lines between 2 lines in a file?
On Wed, Apr 07, 2004 at 03:05:52PM -0400, Tom Buskey [EMAIL PROTECTED] wrote: sed '0,/^uniqdelimiter/d' -e '/^uniqdelimter/d' file Odd, doesn't seem to be working for me. Because I made a mistake. *sigh* I'm having ne of those days when you're afraid to do rm -rf . w/o checking which window directory you're in 1st. sed -e '0,/^uniqdelimiter/d' -e '/^uniqdelimter/,$d' file FWIW, a Perl solution: perl -ne 'print if $m==1 and not /^uniqdelimiter/;$m+=/^uniqdelimiter/;' file That's nicely susinct too. ___ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss