Sponsored Content
Full Discussion: grep string & next n lines
Top Forums Shell Programming and Scripting grep string & next n lines Post 90271 by grasper on Monday 21st of November 2005 08:46:02 AM
Old 11-21-2005
Don't know about non-GNU grep, but you could use sed instead, something like:-

sed -n '/STRING/,$p' filename|head -$n

(where $n is the number of lines you want after the match)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep string but also it will show the next 5 lines

Hi experts, I want to grep a number 9366109380 from a file but it will also show me the next 5 lines. Below is the example- when i grep 989366109380, i can also see the next 5 lines. Line 1. <fullOperation>MAKE:NUMBER:9366109380:PPAY2;</fullOperation> Line 2.... (10 Replies)
Discussion started by: thepurple
10 Replies

2. Shell Programming and Scripting

grep string & a few lines after

i need to grep a STRING_A & the next few lines after the STRING_A example file: STRING_A yada yada line 1 line 2 STRING_B yada yada line 1 line 2 line 3 STRING_A yada yada line 1 line 2 line 3 line 4 STRING_A yada yada line 1 line 2 line 3 line 4 (7 Replies)
Discussion started by: ashterix
7 Replies

3. Shell Programming and Scripting

Like grep -v for a string over 2 lines? Sed?

Hi, I have a log file that I need to monitor as it's being written to, and I want to exclude certain strings from the output. At the moment I'm using ... tail -f LogFileName_`date +%d`.log | egrep -v "First String To Exclude | 2nd string | 3rd string" ...which works OK - but now I need to... (1 Reply)
Discussion started by: jake657
1 Replies

4. Shell Programming and Scripting

Print lines between two lines after grep for a text string

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)
Discussion started by: jbruce
7 Replies

5. Shell Programming and Scripting

Find a string using grep & print the line above or below that.

Hi All, Please tell me how can I Find a string using grep & print the line above or below that in solaris? Please share as I am unable to use grep -A or grep -B as it is not working on Solaris. (10 Replies)
Discussion started by: Zaib
10 Replies

6. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

7. Shell Programming and Scripting

Grep couple of consecutive lines if each lines contains certain string

Hello, I want to extract from a file like : 20120530025502914 | REQUEST | whatever 20120530025502968 | RESPONSE | whatever 20120530025502985 | RESPONSE | whatever 20120530025502996 | REQUEST | whatever 20120530025503013 | REQUEST | whatever 20120530025503045 | RESPONSE | whatever I want... (14 Replies)
Discussion started by: black_fender
14 Replies

8. Shell Programming and Scripting

Grep last two lines, calc & adding comments

....... 06/09/2013|12:00:00 PM|3|26112|40|44032|27419.7|6 1 0 93 |6|1|0|93 06/09/2013|12:30:00 PM|3|26112|40|44032|27491|11 4 0 85 |11|4|0|85 I have "sysperf.out" file containing the lines above. What I like to have on the output is: Node: prod1db ===> this is the hostname Date:... (7 Replies)
Discussion started by: Daniel Gate
7 Replies

9. Shell Programming and Scripting

Grep a string and count following lines starting with another string

I have a large dataset with following structure; C 0001 Carbon D SAR001 methane D SAR002 ethane D SAR003 propane D SAR004 butane D SAR005 pentane C 0002 Hydrogen C 0003 Nitrogen C 0004 Oxygen D SAR011 ozone D SAR012 super oxide C 0005 Sulphur D SAR013... (3 Replies)
Discussion started by: Syeda Sumayya
3 Replies

10. Shell Programming and Scripting

Grep three consecutive lines if each lines contains certain string

say we have : 2914 | REQUEST | whatever 2914 | RESPONSE | whatever 2914 | SUCCESS | whatever 2985 | RESPONSE | whatever 2986 | REQUEST | whatever 2990 | REQUEST | whatever 2985 | RESPONSE | whatever 2996 | REQUEST | whatever 2010 | SUCCESS | whatever 2013 | REQUEST | whatever 2013 |... (7 Replies)
Discussion started by: Saumitra Pandey
7 Replies
Config::Model::DumpAsData(3pm)				User Contributed Perl Documentation			    Config::Model::DumpAsData(3pm)

NAME
Config::Model::DumpAsData - Dump configuration content as a perl data structure VERSION
version 2.021 SYNOPSIS
use Config::Model ; use Log::Log4perl qw(:easy) ; use Data::Dumper ; Log::Log4perl->easy_init($WARN); # define configuration tree object my $model = Config::Model->new ; $model ->create_config_class ( name => "MyClass", element => [ [qw/foo bar/] => { type => 'leaf', value_type => 'string' }, baz => { type => 'hash', index_type => 'string' , cargo => { type => 'leaf', value_type => 'string', }, }, ], ) ; my $inst = $model->instance(root_class_name => 'MyClass' ); my $root = $inst->config_root ; # put some data in config tree the hard way $root->fetch_element('foo')->store('yada') ; $root->fetch_element('bar')->store('bla bla') ; $root->fetch_element('baz')->fetch_with_id('en')->store('hello') ; # put more data the easy way my $step = 'baz:fr=bonjour baz:hr="dobar dan"'; $root->load( step => $step ) ; print Dumper($root->dump_as_data); # $VAR1 = { # 'bar' => 'bla bla', # 'baz' => { # 'en' => 'hello', # 'fr' => 'bonjour', # 'hr' => 'dobar dan' # }, # 'foo' => 'yada' # }; DESCRIPTION
This module is used directly by Config::Model::Node to dump the content of a configuration tree in perl data structure. The perl data structure is a hash of hash. Only CheckList content will be stored in an array ref. Note that undefined values are skipped for list element. I.e. if a list element contains "('a',undef,'b')", the data structure will contain 'a','b'. CONSTRUCTOR
new ( ) No parameter. The constructor should be used only by Config::Model::Node. Methods dump_as_data(...) Return a perl data structure Parameters are: node Reference to a Config::Model::Node object. Mandatory full_dump Also dump default values in the data structure. Useful if the dumped configuration data will be used by the application. (default is yes) skip_auto_write Skip node that have a "perl write" capability in their model. See Config::Model::AutoRead. auto_vivify Scan and create data for nodes elements even if no actual data was stored in them. This may be useful to trap missing mandatory values. ordered_hash_as_list By default, ordered hash (i.e. the order of the keys are important) are dumped as Perl list. This is the faster way to dump such hashed while keeping the key order. But it's the less readable way. When this parameter is 1 (default), the ordered hash is dumped as a list: [ A => 'foo', B => 'bar', C => 'baz' ] When this parameter is set as 0, the ordered hash is dumped with a special key that specifies the order of keys. E.g.: { __order => [ 'A', 'B', 'C' ] , B => 'bar', A => 'foo', C => 'baz' } Methods dump_annotations_as_pod(...) Return a string formatted in pod (See perlpod) with the annotations. Parameters are: node Reference to a Config::Model::Node object. Mandatory experience master, advanced or beginner check_list Yes, no or skip AUTHOR
Dominique Dumont, (ddumont at cpan dot org) SEE ALSO
Config::Model,Config::Model::Node,Config::Model::ObjTreeScanner perl v5.14.2 2012-11-09 Config::Model::DumpAsData(3pm)
All times are GMT -4. The time now is 09:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy