The sed solution, as mentioned above, prints out the delimiting lines. Both the sed and awk solutions will start printing lines as soon as they see a line matching "Start"; they will not wait until the matching "END" is found. This could be relevant if one wants to strictly limit output to sections bounded on both ends by the respective patterns.
In case it's of any use, here's a sed solution that does not print the delimiting lines and that insures that the tail of any printed text is /END/ delimited:
Regards,
Alister
---------- Post updated at 12:00 PM ---------- Previous update was at 11:49 AM ----------
Quote:
Originally Posted by getmmg
Hi, getmmg:
Using the following sample data, for me your suggestion yields nothing (0 bytes of output). Is there something in that one-liner that may not be supported in perl 5.8.6 (it's an old OS X Tiger 10.4.11 machine)? I skimmed over a couple of the perldelta pods for later releases, but nothing jumped out at me.
My sample data:
Expected output:
It's not important, but I'm curious to know. Any ideas?
Disclaimer: When I last regularly hacked with perl, references were new!
Regards,
Alister
Last edited by alister; 06-28-2011 at 01:40 PM..
Reason: Tightened the regular expressions with anchors
Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" .
I have attached sample input file and the desired input should be as:
INPUT FORMAT:
SELECT
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,... (5 Replies)
I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with:
wc -l *|sort
15263 Image.txt
16401 reference.txt
40459 richtexteditor.txt
How can I also print the number of unique lines in each file?
15263 1401 Image.txt
16401... (15 Replies)
URGENT HELP IS NEEDED!!
I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but
- Currently, script is not printing lines to File3.txt in order.
- Also the matching lines are not moving out of File1.txt
... (1 Reply)
Oracle Linux 6.4
In a directory I have more than 300 files with the extension .log
I want the first 5 and last 5 lines of these .log files to be printed on screen with each file's name.
Expected output :
Printing first 5 and last 5 lines of FX_WT_Feb8_2014.log
!! Authentication... (7 Replies)
I am trying to extract a table of data (mysql query output) from a log file. I need to print everything below the header and not past the end of the table. I have spent many hours searching with little progress. I am matching the regexp +-\{99\} with no problem. I just can't figure out how to print... (5 Replies)
I have several very large file that are extracts from Oracle tables. These files are formatted in XML type syntax with multiple entries like:
<ROW>
some information
more information
</ROW>
I want to grep for some words, then print all lines between <ROW> AND </ROW>. Can this be done with AWK?... (7 Replies)
Hi all,
This should be very easy but I can't figure it out...
I have a file that looks like this:
@SRR057408.1 FW8Y5CK02R652T length=34
AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT
+SRR057408.1 FW8Y5CK02R652T length=34
FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8
@SRR057408.2 FW8Y5CK02TBMHV length=52... (1 Reply)
Hi folks
I am not allowed to install GNU grep on AIX.
Here my code excerpt:
grep_fatal () {
/usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP"
}
Howto the same on AIX based machine?
from manual GNU grep
‘--after-context=num’
Print num lines of trailing context after... (4 Replies)