Sponsored Content
Full Discussion: Grep multiple pattern
Top Forums Shell Programming and Scripting Grep multiple pattern Post 302909796 by arpagon on Saturday 19th of July 2014 03:27:36 PM
Old 07-19-2014
Scissors Grep multiple pattern

I have got a text
from each line, I need to fetch port only if there is an ip

Code:
a.text text  and port=25
b.ip=(12.32.54.256) and port="52"
c.ip=(55.251.253.12) and port=25"
d.text text and port="5"
e.ip=(45.211.155.15) and port="457"
f.ip=(144.158.256.2) and port="588"

I know how to fetch ip per line:
Code:
awk 'BEGIN{ RS="<\n>"}1' file | grep -oP "(?<=ip=\()[^)]*"

(well in this case, awk is not very usefull, but in the actual file, it is)

I know how to grab ports individually:

Code:
grep -oP "(?<=port=\")[^\"]*" file

but I do not know how to grab both and only both (line a and d should not be in the output)

Thanx in advance folks!

Last edited by Scrutinizer; 07-19-2014 at 05:26 PM.. Reason: Additional CODE tags
 

10 More Discussions You Might Find Interesting

1. Solaris

Multiple pattern on same line using grep

Hi, I would like to search multiple patterns on same line, i.e. all patterns must present on same line. Please suggest. Thanx (2 Replies)
Discussion started by: sanjay1979
2 Replies

2. Shell Programming and Scripting

Grep with multiple instances of same pattern

Hi, This is my text file I'm trying to Grep. Apple Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received End My Grep command: grep only--matching 'Location.*Received' e. Because the keyword Received appears twice, the Grep command will stop at the last... (0 Replies)
Discussion started by: spywarebox
0 Replies

3. Shell Programming and Scripting

Grep with multiple instances of same pattern

Hi, This is my text file I'm trying to Grep. Apple Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received End My Grep command: grep only--matching 'Location.*Received' Because the keyword Received appears twice, the Grep command will stop at the last... (3 Replies)
Discussion started by: spywarebox
3 Replies

4. Shell Programming and Scripting

Grep multiple line pattern and output the lines

Hi I have the following Input -- -- TABLE: BUSINESS_UNIT -- ALTER TABLE RATINGS.BUSINESS_UNIT ADD CONSTRAINT FK1_BUSINESS_UNIT FOREIGN KEY (PEOPLESOFT_CHART_FIELD_VALUE_ID) REFERENCES RATINGS.PEOPLESOFT_CHART_FIELD_VALUE(PEOPLESOFT_CHART_FIELD_VALUE_ID) ; ALTER TABLE... (1 Reply)
Discussion started by: pukars4u
1 Replies

5. Shell Programming and Scripting

How to grep multiple pattern from XML file

Hi Everyone pls if anyone can help me in writing a script or correcting it what I have done. I want to write a script to grep record number for all those record which have abc xyd cat dog in one of the field say VALUE, I have thousand of file in a dir and I want to search every file for... (6 Replies)
Discussion started by: revertback
6 Replies

6. Shell Programming and Scripting

Grep command with multiple pattern

Hi, I want to search multiple patterns in a variable. DB_ERR=`echo "$DB_TRANS" | grep "SP2-" | grep "ORA-"` echo $DB_ERR But I am not getting anything in DB_ERR. I want to print each line on seperate line. Could you please help me out in this. Thanks in advance. (14 Replies)
Discussion started by: Poonamol
14 Replies

7. Shell Programming and Scripting

Help to search multiple pattern in file with grep/sed/awk

Hello All, I have a file which is having below type of data, Jul 19 2011 | 123456 Jul 19 2011 | 123456 Jul 20 2011 | 123456 Jul 20 2011 | 123456 Here I wanted to grep for date pattern as below, so that it should only grep "Jul 20" OR "Jul ... (9 Replies)
Discussion started by: gr8_usk
9 Replies

8. Shell Programming and Scripting

Grep text between multiple pattern

Hello everybody, I have been looking around but can't figure how to do a grep command, that find the text between multiple patterns, example: (pattern1 OR pattern2) AND (pattern3 OR pattern4) text that I want (pattern5 OR pattern6) AND (pattern7 OR pattern8) So how do I find the "text... (4 Replies)
Discussion started by: Benou
4 Replies

9. Linux

Creating 2 variables from a multiple pattern grep

first time poster here Im pretty new to grep and linux in general and I spent pretty much all day yesterday researching and coming up with a grep command to help with my university project. I am attempting to create a proof of concept bash script to scan the network using ngrep, find appropriate... (7 Replies)
Discussion started by: scottish_jason
7 Replies

10. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies
RSDWNLNK(8)						     Linux Programmer's Manual						       RSDWNLNK(8)

NAME
rsdwnlnk - User exit from the ROSE network. SYNOPSIS
rsdwnlnk <port> <call> DESCRIPTION
The rdwnplnk program allows a user to leave the ROSE network using the standard pseudo-digipeating method. Recent Linux kernels are aware of this form of operation and the ax25d program can create such connections. The normal mode of operation of a ROSE switch is to have one ROSE address (ie port) per physical AX.25 port. Therefore ROSE users coming in on a given ROSE port will come out of the associated AX.25 port. To use rsdwnlnk you need an entry in ax25d.conf to listen for incoming ROSE connections to any callsigns that are not matched by the more specific ROSE entries. In the example below, I will be listening for ROSE connections on my ROSE port rs144, the exiting AX.25 connection will be via the associated AX.25 port, 144, using the callsign KE4GAJ-10. Please note that the callsign should be on the same line as the rest of the command, it may be wrapped onto the next line on your screen. # {* VIA rs144} NOCALL * * * * * * L default * * * * * * - root /usr/sbin/rsdwnlnk rsdwnlnk 144 KE4GAJ-10 # There would typically be one rsdwnlnk per ROSE port. The associated program for entering a ROSE network is rsuplnk. All errors generated by rsdwnlnk are written to the system debug log file. FILES
/etc/ax25/axports SEE ALSO
rose(4), ax25d.conf(5), ax25d(8), rsuplnk(8), rose_call(8). AUTHOR
Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk> Linux 29 April 1997 RSDWNLNK(8)
All times are GMT -4. The time now is 07:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy