Sponsored Content
Top Forums Shell Programming and Scripting Grep couple of consecutive lines if each lines contains certain string Post 302648683 by Ygor on Wednesday 30th of May 2012 08:49:21 AM
Old 05-30-2012
Quote:
Originally Posted by black_fender
I'm not completely emty-handed, I have this snippet as a starting point ('stolen' a while ago from internet :P ) :
Code:
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=1 s="string" file

I recognise my own code from this post: https://www.unix.com/302098992-post2.html

Since I wrote that in 2006, I notice it has propogated over the internet in other forums and blogs, and now seems to have taken a life of its own.

It's not applicable in this case.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep string & next n lines

need help on this. let say i hv 1 file contains as below: STRING Description bla bla bla Description yada yada yada Data bla bla Data yada yada how do i want to display n lines after the string? thanks in advance! (8 Replies)
Discussion started by: ashterix
8 Replies

2. 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

3. 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

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

Merge two non-consecutive lines based on line number or string

This is a variation of an earlier post found here: unixcom/shell-programming-scripting/159821-merge-two-non-consecutive-lines.html User Bartus11 was kind enough to solve that example. Previously, I needed help combining two lines that are non-consecutive in a file. Now I need to do the... (7 Replies)
Discussion started by: munkee
7 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 2 consecutive lines and replace the second line in a file

I have a file lake this cat ex1.txt </DISCOUNTS> <B2B_SPECIFICATION elem="0"> <B2B_SPECIFICATION elem="0"> <DESCR>Netti 2 </DESCR> <NUMBER>D02021507505</NUMBER> </B2B_SPECIFICATION> <B2B_SPECIFICATION elem="1"> <DESCR>Puhepaketti</DESCR>... (2 Replies)
Discussion started by: Dhoni
2 Replies

8. 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

9. 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

10. Shell Programming and Scripting

Remove duplicate consecutive lines with specific string

Hello, I'm trying to remove the duplicate consecutive lines with specific string "WARNING". File.txt abc; WARNING 2345 WARNING 2345 WARNING 2345 WARNING 2345 WARNING 2345 bcd; abc; 123 123 123 WARNING 1234 WARNING 2345 WARNING 2345 efgh; (6 Replies)
Discussion started by: Mannu2525
6 Replies
linphonec(1)						     linphone, internet phone						      linphonec(1)

NAME
linphonec - Console interface of linphone, a SIP compatible internet phone. SYNTAX
linphonec [-d] <debug_level> [-l] <debug_file> [-c] <config_file> linphonec -v DESCRIPTION
Linphonec is the console version of originally Gnome internet phone linphone (http://www.linphone.org) . Linphonec can be started without arguments. It doesn't need any config file to start correctly and will create a default one at the first startup if the file does not exist. By default the path of the config file is ~/.linphonerc . Most parameters (proxy, passwords) can be changed from the command line, for some of them (path of sound rings), you'll need to edit the .linphonerc config file. Once linphonec has started, linphonec wait for some commands and is ready to receive calls. The most important commands are call <sip url> : to call someone. A sip url is in the form sip:user@host terminate : to terminate a call answer : to accept an incoming call. help : to display interactive help. OPTIONS -d <debug_level> Use debug mode with given verbosity (debug_level). The debug_level is an integer in the range 0..5 . -h Output help information and exit. -l <log_file> Specifies a file where debug information will be written. Default is stdout. -c <config_file> Specifies the config file to read at startup. FILES ~/.linphonec ENVIRONMENT VARIABLES
EXAMPLES
AUTHORS
Florian Winterstein <fwin at gmx.de> Simon Morlat <simon.morlat at linphone.org> SEE ALSO
linphone(1) sipomatic(1) Florian Winterstein &; Simon MORLAT 1.0.0 linphonec(1)
All times are GMT -4. The time now is 01:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy