Printing a block of lines from a file, if that block does not contain two patterns using sed
I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed.
See below for the example data.
Code:
................................server 1...............................
running process 1
running process 2
running process 3
date : 12/12/2012
............................................................................
................................server 2...............................
running process 1
stopped process 2
running process 3
date : 13/12/2012
............................................................................
in the above mentioned file a block refers from
.........server................. to ........................
in that block i have to check, if there is no pattern "stop" and "13/12/2012" then i have to print that block.
this is what i have tried till now
Code:
sed -n -e '/./{H;/\.\.\.\./!d;}' -e 'x;/stop/ !{ /13.12.2012/ !{p;}}' example
the output iam getting is given below
Code:
................................server 1...............................
................................server 1...............................
running process 1
running process 2
running process 3
date : 12/12/2012
............................................................................
............................................................................
................................server 2...............................
The required output is
Code:
................................server 1...............................
running process 1
running process 2
running process 3
date : 12/12/2012
............................................................................
Please let me know what am I doing wrong.
Last edited by Scrutinizer; 12-21-2012 at 09:32 AM..
Reason: icode to code tagss
Hi
I am new to this forum.
I have few XML files and from each xml file I want to copy some specific 50 no of lines and copy them to some other file.
how to do that? pls help.. (5 Replies)
Dear All,
Regards of the Day.
I have a text file with some functions:
Function1
{
parameter 1
parameter 2
parameter 3
}
end
Function2
{
parameter 1
parameter 2
parameter 3
} (1 Reply)
Hi Gurus,
I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
hello
im new here so i want to say hi everybody :)
i have to write a script and im newbie :/ i hope that in this forum are many ppl who knows subject :)
i have hundrets folders. in each folder is a file name trace.txt. each trace.txt has a lot of tracert's results separates with "-----" it... (6 Replies)
Hi Friends,
I have a file which has many of the statements like below
******** MAKING > noun1 < cg_all
statements
statements
statements
********* MAKING > noun2 < cg_all
statements
statements
statements
********* MAKING > noun3 < all
statements
statements
statements
I would... (3 Replies)
Hi all ,
i need an help here.!!!! i have a file that contains /etc/passwd files from some servers.
i need a script which search for presence of a user in the servers.
like if i give 51144 to the script. the should be o/p
Please help on this..... (4 Replies)
I have a "main" file which has blocks of data for each user defined by tags BEGIN and END.
BEGIN
ID_NUM:24879
USER:abc123
HOW:47M
CMD1:xyz1
CMD2:arp2
STATE:active
PROCESS:id60
END
BEGIN
ID_NUM:24880
USER:def123
HOW:4M
CMD1:xyz1
CMD2:xyz2
STATE:running
PROCESS:id64
END (7 Replies)
Hi,
In order to make our debugging easier in log files, I need this script.
My log file will be structured like this :
------Invoking myfile -param:start_time=1371150900000 -param:end_time=1371151800000 for 06/14/2013
<multiple lines here>
.....
- Step Sybase CDR Table.0 ended... (3 Replies)
Discussion started by: Lakshmikumari
3 Replies
LEARN ABOUT FREEBSD
ypset
YPSET(8) BSD System Manager's Manual YPSET(8)NAME
ypset -- tell ypbind(8) which YP server process to use
SYNOPSIS
ypset [-h host] [-d domain] server
DESCRIPTION
The ypset utility tells the ypbind(8) process on the current machine which YP server process to communicate with. If server is down or is
not running a YP server process, it is not discovered until a YP client process attempts to access a YP map, at which time ypbind(8) tests
the binding and takes appropriate action.
The ypset utility is most useful for binding a YP client that is not on the same broadcast network as the closest YP server, but can also be
used for debugging a local network's YP configuration, testing specific YP client programs, or binding to a specific server when there are
many servers on the local network supplying YP maps.
The options are as follows:
-h host
Set the YP binding on host instead of the local machine.
-d domain
Use the YP domain domain instead of the default domain as returned by domainname(1).
SEE ALSO domainname(1), ypcat(1), ypmatch(1), yp(8), ypbind(8)AUTHORS
Theo De Raadt
BSD October 25, 1994 BSD