Sponsored Content
Top Forums Shell Programming and Scripting How to search for keywords in subsequent lines Post 302342545 by Franklin52 on Monday 10th of August 2009 07:28:49 AM
Old 08-10-2009
Quote:
Originally Posted by rdhanek
Thank you all for the inputs.

Franklin52, your code is working perfectly.

Apart from printing,Can i have the code for the deleteion of those lines from the input file?
Redirect the output to another file and replace the original file with it:

Code:
awk '..' file > newfile
mv newfile file

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace only 1st word of a line if it comes in the subsequent lines at same postion.

I have a file like this.. Maharastra Mumbai worli Maharastra Mumbai navy maharatra Pune Maharastra Nagpur Karnataka Bangalore Karnataka Mysore Karnataka Mangalore Punjab Amritsar punjab Jalandar my expected outcome should be like this Maharastra Mumbai worli ---------- ... (9 Replies)
Discussion started by: geeko
9 Replies

2. Shell Programming and Scripting

How to extract a substring and append to subsequent lines

Hi all,I am really new to Shell Scripting.I have the following doubt. Let us assume the one sample file which contains the below data HEADERCARMENTRACIE1555090414 PERIOD0905090501090531 DETAIL0645693037023073836 GROUNDAV 090501 01 GROUNDAV 090502 01 TRIP 0091282542 0905084101... (5 Replies)
Discussion started by: jaligamasriniva
5 Replies

3. Shell Programming and Scripting

search for keyword in subsequent lines and delete the second line

I have my data something like this I need to search for the keyword yyyy in the susequent lines and if it is present, delete the second line with keyword. In other words, if a keywords is found in two subsequent lines delete the second line. input data: aaaa bbbbb cccc dddd xxxx... (4 Replies)
Discussion started by: rdhanek
4 Replies

4. Shell Programming and Scripting

Grep and fetch subsequent lines also

Hi, I need to grep a pattern and fetch subsequent lines till end of the data-set. E.g., i have a file like: AA 1111 23 34 BB 45 56 78 CC 22 44 AA 2222 78 34 56 BB 22 56 67 68 23 CC 56 78 DD 33 55 77 AA 3333 46 BB 58 79 In above file i have 3-data sets where each set starts with... (6 Replies)
Discussion started by: prvnrk
6 Replies

5. Shell Programming and Scripting

Find pattern, and then last field from subsequent lines

I've got a log file, of the format Name: network1 Dropped packets: 15618 Dropped packets for IPv6: 27 Dropped packets: 74 Dropped packets for IPv6: 0 Failed RADIUS Authentication procedures: 0 Failed RADIUS Accounting procedures: 0 Name: network2 Dropped packets: 1117 ... (18 Replies)
Discussion started by: Yorkie99
18 Replies

6. Shell Programming and Scripting

Search a file with keywords

Hi All I have a file of format asdf asf first sec endi asdk rt 123 ferf dfg ijglkp (7 Replies)
Discussion started by: mailabdulbari
7 Replies

7. Shell Programming and Scripting

awk - use fields from subsequent lines

I've run into a problem getting exactly what I want out of awk - some folks may recognize this as an output from Amazon's ec2-describe-instances: Given the following: INSTANCE i-4960f321 BLOCKDEVICE Line2Var2 TAG instance i-4960f321 Name web1 TAG instance i-4960f321... (2 Replies)
Discussion started by: colinjohnson
2 Replies

8. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

9. UNIX for Advanced & Expert Users

Need command for grepping pattern lines with subsequent lines

Hi, I have a requirement like, I have a list of pattens in a file say pattern.txt, PHC111 PHC113 and in another file called master.lst i have entries like, PHC111 a b PHC112 a PHC113 b c PHC114 d e (5 Replies)
Discussion started by: rbalaj16
5 Replies
SNOWDROP(1)						      General Commands Manual						       SNOWDROP(1)

NAME
sd-eng, sd-engf, sd-c - text watermarking and watermark recovery SYNOPSIS
sd-eng [-6] -i origfile newfile "Recipient" ["Comment"] sd-eng [-6] -e origfile newfile sd-eng [-6] -l DESCRIPTION
snowdrop is a stenographic text watermarking and watermark recovery system. It is composed of three programs: sd-eng Watermark normal English text. sd-engf Watermark fine quality English text, yeilding higher quality output but encoding less information. sd-c Watermark C code. The three programs operate similarly, with the same parameters and usage. The watermark is encoded in using a number of techniques, such as whitespace reformatting, typo insertation, word substitutions, punctuation changes, and for C code, logic reordering, variable name man- gling, etc. The watermark is a md5sum, which is retreivable from as little as 5 or 10 lines of the watermarked document. Even large changes to a medium sized document should not obscure the watermark, as it is stored redundently in multiple independent channels. The three usage modes are adding a watermark, checking for the presense of a watermark, and listing the contents of your database of water- marks. Note that to later check a watermark, you must retain a copy of the original, un-watermarked file. OPTIONS
-i Inject a watermark into a file. You must pass it the original file, the filename to output the watwrmarked version to, information about who you intend the watermarked file for, and an optional comment. -e Extract a watermark from a file. Needs the original file and the new file that you suspect bears the watermark. -l Lists the contents of the watermark database. Each of the three programs will have a different list. -6 Enable 64 bit watermarking. The default is a weak 32 bit watermark. ENVIRONMENT
SD_SYNONYMS This variable can be used to point snowdrop at a customized synonyms file. FILES
~/.snowdrop/database Database of watermarked files. SEE ALSO
/usr/share/snowdrop/README Explain snowdrop in more depth, its limitations, and how to write additional watermarking modules for other tpyes of files. AUTHOR
Michal Zalewski <lcamtuf@coredump.cx> SNOWDROP(1)
All times are GMT -4. The time now is 02:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy