Quote:
Originally Posted by Feynman
Thank you grail. Well, with the given awk commands, I have 4/5 task covered.
|
good to hear
Quote:
My description of the unsolved task was admittedly vague so I rewrote it in an earlier post. I will work on/copy-past from that cookbook site/get some help with perl programs that do the equivalent.
|
the equivalent of awk from that cookbook page.
Perl
Code:
while (<>) {
if (/BEGIN PATTERN/ .. /END PATTERN/) {
# line falls between BEGIN and END in the
# text, inclusive.
}
}
awk
Code:
awk '/BEGIN PATTERN/,/END PATTERN/' file
Perl
Code:
while (<>) {
if ($FIRST_LINE_NUM .. $LAST_LINE_NUM) {
# operate only between first and last line, inclusive.
}
}
awk
Code:
awk 'NR>first && NR < last' file
I am just showing you alternatives tools/ways for doing your task. It is up to you to use Perl/Python or whatever you like, but just don't intermix too much of different tools (Perl, awk, etc) in your application because their functions overlap. It will be messy. If you want to do it with Perl/Python/Ruby, then do everything with it.