![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sed selective data parsing | dunstonrocks | Shell Programming and Scripting | 1 | 03-29-2009 07:00 AM |
| Another data extraction question | kunigirib | Shell Programming and Scripting | 6 | 12-24-2008 06:36 PM |
| Data Extraction From a File | rrangaraju | Shell Programming and Scripting | 3 | 12-23-2008 04:26 PM |
| help with data extraction script | mam | Shell Programming and Scripting | 11 | 01-16-2008 06:50 AM |
| Data Extraction issue. | irehman | Shell Programming and Scripting | 5 | 04-06-2006 09:28 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Selective extraction of data from a files
Hi,
I would like to seek for methods to do selective extraction of line froma file. The scenario as follows: I have a file with content: [RECV] message a received on 11:10:00 file size: 10 bytes send by abc [End] [RECV] message b received on 11:20:00 file size: 10 bytes send by abc [End] [RECV] message c received on 11:30:00 file size: 10 bytes send by abc message d received on 11:40:00 file size: 10 bytes send by abc [End] I will like to extract the last [RECV] portion from the file i.e message c and d. The [RECV] and [End] is fixed but the number of message in each portion is not fixed. Thank for the advice. Cheer |
|
||||
|
Code:
local $/="[End]\n\n";
my $tmp;
while(<DATA>){
$tmp=$_;
}
print $tmp;
__DATA__
[RECV]
message a
received on 11:10:00
file size: 10 bytes
send by abc
[End]
[RECV]
message b
received on 11:20:00
file size: 10 bytes
send by abc
[End]
[RECV]
message c
received on 11:30:00
file size: 10 bytes
send by abc
message d
received on 11:40:00
file size: 10 bytes
send by abc
[End]
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|