06-19-2012
Printing nth and n+1th line after a pattern match
Hi ,
I want to print the nth and n+1 lines from a file once it gets a pattern match.
For eg:
aaa
bbb
ccc
ddd
gh
jjjj
If I find a match for bbb then I need to print bbb as well as 3rd and 4th line from the match.. Please help..Is it possible to get a command using sed
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
folks..
i need a simple one liner to extract data from between the (n)th and (n+1)th instance of a line in a 2 colum file.
eg....for n=3 i should get back
0 1
4 6
help would be much appreciated.
file blah.txt
##################
identifer line
0 3
0 3
identifer line
0 2
0... (5 Replies)
Discussion started by: ryanp200
5 Replies
2. Shell Programming and Scripting
Hi,
I have many scripts in particular directory. And few of the scripts have exit 0 in second line. Now i wanted to list out the scripts name which has the exit 0 in its second line
I tried many options , but i can not get the filename along with the nth line pattern match :mad:. Can anyone... (14 Replies)
Discussion started by: puni
14 Replies
3. Shell Programming and Scripting
Hi,
I am looking for any script which can do the following.
have to read a pattern from fileA and copy it to fileB.
fileA:
...
...
Header
...
...
..p1
...
...
fileB:
....
....
Header (3 Replies)
Discussion started by: anilvk
3 Replies
4. Shell Programming and Scripting
Hi,
I am getting crazy after days on looking at it:
Bash in Ubuntu 12.04.1
I want to do this:
pattern="system /path1/file1 file1"
new_pattern=" data /path2/file2 file2"
file to edit: data.db
- I need to search in the file data.db for the nth occurrence of pattern
- pattern must... (14 Replies)
Discussion started by: Phil3759
14 Replies
5. Shell Programming and Scripting
Hi, i have a big file having many opcodes.
if (opcode="01110000000100000000" ) then --fadd
result.opcode := "01110000000100000000";
result.s0 := '1';
result.s1 := '1';
result.s2 := '0';
result.inst := '0';
result.scalar := '1';... (7 Replies)
Discussion started by: twistedpair
7 Replies
6. Shell Programming and Scripting
Im using the command below , but thats not the output that i want. it only prints the odd and even numbers.
awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}'
Im hoping for something like this
file1:
Text hi this is just a test
text1 text2 text3 text4 text5 text6
Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies
7. Shell Programming and Scripting
Hi All,
I have sample of listing as following
Database 2 entry:
Database alias = PXRES
Database name = PXRES
Local database directory = /db2/data1/db2phnx
Database release level = d.00
Comment ... (3 Replies)
Discussion started by: ckwan
3 Replies
8. Shell Programming and Scripting
I am trying to combine lines with these conditions:
1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text.
2. If condition1 is met then continue to combine lines through a line that ends with a semicolon.
3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies
9. AIX
Please help me
print nth line after match
awk or sed one line command. (3 Replies)
Discussion started by: sushma123
3 Replies
10. Shell Programming and Scripting
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
LEARN ABOUT DEBIAN
torrus_action_notify
TORRUS_ACTION_NOTIFY(7) torrus TORRUS_ACTION_NOTIFY(7)
NAME
action_notify - Generic notification handler for Torrus monitor
SYNOPSIS
<action name="notify">
<param name="action-type" value="exec" />
<param name="command">
$TORRUS_BIN/action_notify
</param>
<param name="launch-when" value="set" />
</action>
DESCRIPTION
This program is designed for usage from a monitor action only. It takes the arguments from environment variables, as described in action-
type "exec" in Torrus XML Configuration Guide.
The handler reads its configuration from <notify-siteconfig.pl>, a small Perl file which defines the notification paths for various
conditions.
Example:
%Torrus::Notify::programs =
(
'mailto' => '$TORRUS_BIN/action_printemail | /usr/bin/mail $ARG1',
'page' => '/usr/bin/echo $TORRUS_NODEPATH:$TORRUS_MONITOR ' .
'>> /tmp/monitor.$ARG1.log'
);
%Torrus::Notify::policies =
(
'CUST_A' => {
'match' => sub { $ENV{'TORRUS_P_notify_policy'} eq 'A' },
'severity' => {
'3' => [ 'mailto:aaa@domain.com',
'mailto:bbb@domain.com' ],
'5' => [ 'page:1234', 'mailto:boss@domain.com' ] } } );
In this example, we define two message handlers: e-mail sender and a dummy replacement for a pager program. Then we define the notification
policies. For the customer A, we define the policy so that the parameter "notify-policy" should match the name "A". The parameter is
defined in the datasource tree and marks only those leaves that belong to this customer. Then, depending on the monitor severity,
different notification paths are defined. For severity values higher or equal 3, aaa@domain.com and bbb@domain.com will receive the email
notifications, and for severity higher than or equal 5 all recipients will receive the notification.
The "match" argument is a Perl subroutine, and can depend on various parameters, such as time of day or day of the week, the tree name, and
so on.
FILES
/etc/torrus/conf/notify-siteconfig.pl
Notification policies configuration
SEE ALSO
torrus(8)
NOTES
See more documentation at Torrus home page: http://torrus.org
AUTHOR
Stanislav Sinyagin <ssinyagin@yahoo.com>
torrus 2.03 2013-07-26 TORRUS_ACTION_NOTIFY(7)