search and replace, when found, delete multiple lines, add new set of lines?
hey guys,
I tried searching but most 'search and replace' questions are related to one liners.
Say I have a file to be replaced that has the following:
This is the input file:
What I want to do is, search testing.txt for "EEE". When I find "EEE", I want to delete "EEE" and two lines below it ending in "GGG". I want to replace "EEE" through "GGG" with the input.txt file. So the ending results will look like:
I know how to search for single lines of code and replace that line with something else.
How do I say "find this line, delete three lines down, replace it with text from this input file"?
thanks.
---------- Post updated at 02:39 PM ---------- Previous update was at 02:32 PM ----------
I have a file which contains blocks of text - each block is a multi-lines text delimited by blank lines eg.
<blank line>
several lines of text
...
pattern found on this line
several more lines of text
...
<blank line>
How do you delete the block of text (including the blank lines) when... (17 Replies)
Hi, I've been searching in this forum for the last 4 hours trying to do one thing: search 2 lines and delete the above line. So far I have not be able to find something similar in this forum, so I need help. This is what I'm trying to do. For example, I have a file called file1:
file1
word1... (4 Replies)
I have sql's in a file separated by ";", need to put the sql in one single line till i find a ";" The input file is like this
SELECT s.sid,
s.serial#,
p.spid as "OS PID",
s.username,
s.module,
... (6 Replies)
Hi Experts,
i am beginner in perl and need your help to find a solution.. I have a block of multiple lines like below say module 1 to module 100
***** MAKING > module1 **************
kvmfkvmmfdv
svksmnvlksmfvks dcsdvcs
sddvcsv ssvsdvdf error: abcdefghi
wrw wvsv dsvds sdvsd
error:... (5 Replies)
All I want is to look for the pattern in the file...If I found it at # places... I want print lines after those pattern(line) until I find a blank line.
Log EXAMPLE :
MT:Exception caught
The following Numbers were affected:
1234
2345
2346
Error
java.lang.InternalError:... (3 Replies)
HI group members
I am new in unix
I want to search # symbol in a file.
if found need to delete the entire row in the file.
need to move the actual data(with out # symbol data) to another file.
Thanks (2 Replies)
Hi All,
Am very new for this Shell scripting.
Could anyone pls let me know how to delete a set of lines from a (.DAT) file using ksh script.
for example from line 3 to line 7. The size of the target file is huge:(
---------- Post updated at 11:01 PM ---------- Previous update was at 11:00 PM... (5 Replies)
Hi Everyone!
I would like ask if there's a better way I can delete multiple lines in a file1 by collecting all criteria from file2.
file1:
a
b
c
d
e
f
file2:
a
e
f
The expected value will be:
b (3 Replies)
This is for AIX 6.1, I've a flat file and the format is like this
DECLARE
some statements;
BEGIN
some statements;
END;
I've to search BEGIN and replace it with the following 4 lines
BEGIN
For x in 1..1
LOOP
BEGIN
Similarly I've to search END and replace it with the... (7 Replies)
Hi all,
I'm looking for a way (sed or awk) to delete multiple lines between blank lines containing two patterns ex:
user: alpha
parameter_1 = 15
parameter_2 = 1
parameter_3 = 0
user: alpha
parameter_1 = 15
parameter_2 = 1
parameter_3 = 0
user: alpha
parameter_1 = 16... (3 Replies)
Discussion started by: ce9888
3 Replies
LEARN ABOUT CENTOS
ausearch_add_timestamp_item
AUSEARCH_ADD_TIMESTAMP_ITEM(3) Linux Audit API AUSEARCH_ADD_TIMESTAMP_ITEM(3)NAME
ausearch_add_timestamp_item - build up search rule
SYNOPSIS
#include <auparse.h>
int ausearch_add_timestamp_item(auparse_state_t *au, const char *op, time_t sec, unsigned milli, ausearch_rule_t how)
DESCRIPTION
ausearch_add_timestamp_item adds an event time condition to the current audit search expression. The search conditions can then be used to
scan logs, files, or buffers for something of interest. The op parameter specifies the desired comparison. Legal op values are <, <=, >=, >
and =. The left operand of the comparison operator is the timestamp of the examined event, the right operand is specified by the sec and
milli parameters.
The how value determines how this search condition will affect the existing search expression if one is already defined. The possible val-
ues are:
AUSEARCH_RULE_CLEAR
Clear the current search expression, if any, and use only this search condition.
AUSEARCH_RULE_OR
If a search expression E is already configured, replace it by (E || this_search_condition).
AUSEARCH_RULE_AND
If a search expression E is already configured, replace it by (E && this_search_condition).
RETURN VALUE
Returns -1 if an error occurs; otherwise, 0 for success.
APPLICATION USAGE
Use ausearch_add_item(3) and ausearch_add_interpreted_item(3) to add conditions that check audit record fields. Use ausearch_add_expres-
sion(3) to add complex search expressions using a single function call.
SEE ALSO ausearch_add_expression(3), ausearch_add_item(3), ausearch_add_interpreted_item(3), ausearch_add_regex(3), ausearch_set_stop(3), ause-
arch_clear(3), ausearch_next_event(3), ausearch-expression(5).
AUTHOR
Miloslav Trmac
Red Hat Nov 2007 AUSEARCH_ADD_TIMESTAMP_ITEM(3)