10-06-2010
Search and Extract data between two strings
hi,
In a given directory, i need to search for a string (eg:ABCD).
For a given file, i have to extract the text between START and END strings .
I need to extract all the text between START and END and there can be multiple START and END in a file.
Sample:
There is a directort dir1. In that there are files file1 and file2.
Quote:
file 1 contents:
-------------
//START
//ABCD
//.........
//......
//END
Quote:
file 2 contents:
-------------
//START
//ABCD
//.........
//......
//END
.............
...............
..............
................
//START
//
//.........
//......
//END
i would be grepping the file using ABCD string .
I am trying to write a script to extract the text from the files between START and END.
Can anybody please hel me in this.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
My input file:
data_5 Ali 422 2.00E-45 102/253 140/253 24
data_3 Abu 202 60.00E-45 12/23 140/23 28
data_1 Ahmad 256 7.00E-45 120/235 140/235 22
data_4 Aman 365 8.00E-45 15/65 140/65 20
data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies
2. Shell Programming and Scripting
My input:
Data name: ABC001
Data length: 1000
Detail info
Data Direction Start_time End_time Length
1 forward 10 100 90
1 forward 15 200 185
2 reverse 50 500 450
Data name: XFG110
Data length: 100
Detail info
Data Direction Start_time End_time Length
1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies
3. Shell Programming and Scripting
Hi , I have a billing CDR file which has repeated lines as indicated below and I need to extract data between two strings (i.e.: <?> and </?>). Eventually, map that information with the corresponding field. I'm new to unix, any help will be greatly appreciated.
Gamini
Input (single line):
!... (3 Replies)
Discussion started by: jaygamini
3 Replies
4. Shell Programming and Scripting
Hi , I have a billing CDR file which is separated by “!”. I need to extract and format data between the starting (“!”) and the end of the line (“1.2.1.8”). These two variables are permanent tags to show begin and end.
! TICKET NBR : 2 ! GSI : 101 ! 3100.2.112.1 24/03/2010 00:41:14 !... (3 Replies)
Discussion started by: jaygamini
3 Replies
5. Shell Programming and Scripting
I have a huge file (about 2 millions records) contains data separated by “,” (comma). As part of the requirement, I can't change the format. The objective is to remove some of the records with the following condition. If the 23rd field on each line start with 302 , I need to remove that from the... (4 Replies)
Discussion started by: jaygamini
4 Replies
6. Shell Programming and Scripting
I have a file with
<suit:run date="Trump Tue 06/19/2012 11:41 AM EDT" machine="garg-ln" build="19921" level="beta" release="6.1.5" os="Linux">
Need to find word "build" then
extract build number, which is 19921 also
release number, which is 6.1.5 then
concatenate them to one variable as... (6 Replies)
Discussion started by: garg
6 Replies
7. Shell Programming and Scripting
I have hundreds of files to process. In each file
I need to look for a pattern then
extract value(s) from next line and then
search for value(s) selected from point (2) in the same file at a specific position.
HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V
TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies
8. Shell Programming and Scripting
I have the following lines in a log file. It would be great if some one can help me to create a new file with the just entries in the below format.
66.150.161.195 HPSAC=Z05
66.150.161.196 HPSAC=A05
That is just extract the IP address and the string DPSAC=its value
66.150.161.195 -... (1 Reply)
Discussion started by: Tuxidow
1 Replies
9. Shell Programming and Scripting
Based on the forums i have tried with grep command but i am unable to get the required output.
search this value /*------
If that is found then search for temp_vul and print
and also search until /*------- and print new_vul
Input file contains:
... (5 Replies)
Discussion started by: onesuri
5 Replies
10. UNIX for Dummies Questions & Answers
Dear all,
I have a data like below (n of rows=400,000) and I want to extract the rows with certain strings. I use code below. It works if there is not too many strings for example n of strings <5000. while I have 90,000 strings to extract. If I use the egrep code below, I will get error:
... (3 Replies)
Discussion started by: forevertl
3 Replies
LEARN ABOUT DEBIAN
template::timer
Timer(3pm) User Contributed Perl Documentation Timer(3pm)
NAME
Template::Timer - Rudimentary profiling for Template Toolkit
VERSION
Version 1.00
SYNOPSIS
Template::Timer provides inline timings of the template processing througout your code. It's an overridden version of Template::Context
that wraps the "process()" and "include()" methods.
Using Template::Timer is simple.
use Template::Timer;
my %config = ( # Whatever your config is
INCLUDE_PATH => '/my/template/path',
COMPILE_EXT => '.ttc',
COMPILE_DIR => '/tmp/tt',
);
if ( $development_mode ) {
$config{ CONTEXT } = Template::Timer->new( %config );
}
my $template = Template->new( \%config );
Now when you process templates, HTML comments will get embedded in your output, which you can easily grep for. The nesting level is also
shown.
<!-- TIMER START: L1 process mainmenu/mainmenu.ttml -->
<!-- TIMER START: L2 include mainmenu/cssindex.tt -->
<!-- TIMER START: L3 process mainmenu/cssindex.tt -->
<!-- TIMER END: L3 process mainmenu/cssindex.tt (17.279 ms) -->
<!-- TIMER END: L2 include mainmenu/cssindex.tt (17.401 ms) -->
....
<!-- TIMER END: L3 process mainmenu/footer.tt (3.016 ms) -->
<!-- TIMER END: L2 include mainmenu/footer.tt (3.104 ms) -->
<!-- TIMER END: L1 process mainmenu/mainmenu.ttml (400.409 ms) -->
Note that since INCLUDE is a wrapper around PROCESS, calls to INCLUDEs will be doubled up, and slightly longer than the PROCESS call.
AUTHOR
Andy Lester, "<andy at petdance.com>"
BUGS
Please report any bugs or feature requests to "bug-template-timer at rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I
will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
ACKNOWLEDGEMENTS
Thanks to Randal Schwartz, Bill Moseley, and to Gavin Estey for the original code.
COPYRIGHT & LICENSE
This library is free software; you can redistribute it and/or modify it under the terms of either the GNU Public License v3, or the
Artistic License 2.0.
* http://www.gnu.org/copyleft/gpl.html
* http://www.opensource.org/licenses/artistic-license-2.0.php
perl v5.12.4 2009-03-07 Timer(3pm)