Sponsored Content
Top Forums Shell Programming and Scripting sed remembering part of pattern using \1 concept Post 302326106 by indianjassi on Wednesday 17th of June 2009 05:58:14 AM
Old 06-17-2009
sed remembering part of pattern using \1 concept

I am using this concept to fetch value of IP address after node= in this line of csv text:

Code:
a="Measurement:,OutInviteResponseTime,Sessionid=1860700092328051458,node=67.178.40.168,nodeName=abcd,protocol=GK,25523000"

echo $a | sed 's/.*node=\(.*\).*/\1/'

But this outputs:
Code:
67.178.40.168,nodeName=CHCIILNQPS1_Area4_67.178.40.168,protocol=SIP,25523000

I only want output till 67.178.40.168, that is, text between node= and comma (,).

Note: I can't use AWK on this because the columns are variable in input.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to get the last part of a string followed by a pattern

assuming "cat" is the pattern, string (regardless length) asdadfcat4 I need to get 4 for eirtrjkkkcat678- I'd get 678 (in b-shell) Thanks in advance!!! (4 Replies)
Discussion started by: bluemoon1
4 Replies

2. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

3. Shell Programming and Scripting

Selecting a part of the text (regex pattern, awk, sed)

Hello, let's start by giving you guys a few examples of the text: "READ /TEXT123/ABC123" "READ /TEXT123/ABC123/" "READ TEXT123/ABC123" "READ TEXT123/ABC123/" "READ TEXT123/TEXT456/ABC123" "READ /TEXT123/TEXT456/ABC123" "READ /TEXT123/TEXT456/ABC123/" TEXT and ABC can be and I... (5 Replies)
Discussion started by: TehOne
5 Replies

4. Shell Programming and Scripting

Replacing part of a pattern in sed

Hi I have a piece of xml that has a pattern like this <int>159</int><int>30</int> I want to find this pattern but only substitute the second part of the pattern to {rid1}. Is that possible in sed ? Thanks. ---------- Post updated at 12:10 PM ---------- Previous update was at 12:01 PM... (11 Replies)
Discussion started by: vnn
11 Replies

5. Red Hat

nautilus is not remembering settings

nautilus is not remembering my settings. I have done everything I can think of to get this to work. I have deleted .gconf, .gconfd, and .gnome2. I tried to start over fresh and that did not work either. What else can I do? (4 Replies)
Discussion started by: cokedude
4 Replies

6. Shell Programming and Scripting

How to use sed to search a particular pattern in a file backward after a pattern is matched.?

Hi, I have two files file1.txt and file2.txt. Please see the attachments. In file2.txt (which actually is a diff output between two versions of file1.txt.), I extract the pattern corresponding to 1172c1172. Now ,In file1.txt I have to search for this pattern 1172c1172 and if found, I have to... (9 Replies)
Discussion started by: saurabh kumar
9 Replies

7. What is on Your Mind?

Remembering your password

I read about this guy who always had difficulty remembering his password so he changed his password to "incorrect". Now when he tries to log in and it fails the system tells him "your password is incorrect". (2 Replies)
Discussion started by: hicksd8
2 Replies

8. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

9. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

10. Shell Programming and Scripting

[sed] Finding and sticking the pattern to the beginning of successive lines up to the next pattern

I have a file like below. 2018.07.01, Sunday 09:27 some text 123456789 0 21 0.06 0.07 0.00 2018.07.02, Monday 09:31 some text 123456789 1 41 0.26 0.32 0.00 09:39 some text 456789012 1 0.07 0.09 0.09 09:45 some text 932469494 1 55 0.29 0.36 0.00 16:49 some text 123456789 0 48 0.12 0.15 0.00... (9 Replies)
Discussion started by: father_7
9 Replies
Net::SIP::SDP(3pm)					User Contributed Perl Documentation					Net::SIP::SDP(3pm)

NAME
Net::SIP::SDP - Parsing and manipulation of SDP data for SIP SYNOPSIS
my $sdp = Net::SIP::SDP->new( sdp_string ); my @media = $sdp->get_media; DESCRIPTION
Net::SIP::SDP can parse and manipulate SDP data. It's not a general purpose SDP class (like Net::SDP) but designed to work with SDP data contained in SIP packets and for easy extraction and manipulation (for NAT etc) of media information contained in the SDP. The class is also designed for easy creation of SDP bodies in the context of the rest of Net::SIP::*. EXAMPLES
# creation based on media data my $sdp = Net::SIP::SDP->new( { addr => '192.168.0.1' }, { port => 2012, proto => 'RTP/AVP', media => 'audio', fmt => 0 }, { port => 2014, proto => 'RTP/AVP', media => 'video', fmt => 0 }, ); # parse from string my $sdp = Net::SIP::SDP->new( sdp_string ); # extract all media data my @media = $sdp->get_media; # and replace them with new addr + port (for NAT) my @new_media,; foreach (@media) { my ($port,@socks) = create_rtp_sockets( '192.168.178.1', $_->{range} ); push @new_media, [ '192.168.178.1', $port ]; ... } $sdp->replace_media_listen( @new_media ); CONSTRUCTOR
new Default constructor. Depending on kind of arguments branches into new_from_string or new_from_parts. See there. new_from_string ( STRING ) Creates object from STRING containing the SDP data. Raises an exception (e.g. die()) if SDP is invalid. new_from_parts ( \%GLOBAL, @MEDIA ) Creates object from specification. %GLOBAL describes the global keys, usually only a common "addr" for all media but any of the keys defined in RFC2327 can be used. @MEDIA is a list of hash references, one hash for each media part. These hashes can contain as keys the one-letter keys specified in RFC2327 and/or special keys for constructing the 'c' and 'm' line: addr - The address, used in the 'c' line. port - The port number range - Range of ports, for RTP/AVP defaults to 2, else 1 media - The media typ, e.g. 'audio','video',... proto - Transport protocol, ususally 'RTP/AVP' or 'udp' If the SDP should contain multiple values for the same key in the same media section on can specifiy the value for the key as a @list instead of a string (this is often the case for 'a' lines). METHODS
as_string Returns string representation for object. content_type Returns 'application/sdp' get_media Returns list of all media described in the SDP. If the caller expects an array the result will be a list, otherwise a reference to a list. Each element of the list is a hash with the following keys: addr - IP4/IP6 address for media port - Start port range - Range for ports proto - Media proto, usually 'RTP/AVP' or 'udp' media - Media typ, usually 'audio', 'video' or 'data' fmt - Format info from media line as @list, e.g "[ 0,10,5 ]". lines - All lines from media description as @list of [ key,value ]. WARNING! You should never manipulate the values you got from this function, because this might affect the objects internals. replace_media_listen ( NEW_MEDIA ) Replaces the exisisting media in the object with new media. Useful for NAT. NEW_MEDIA is ether an array or a reference to an array. Each element in the list consists of the new [ addr,port ] mapping for the matching media entry. The number of entries in the list should be the same as the number of media entries in the object ( see get_media ). If this is not the case it will "die()". name2int ( NAME, INDEX ) Returns the RTP payload id for NAME (e.g. "telephone-event/8000"). INDEX is the index into the list of media information, matching the list returned from get_media. INDEX can also be 'audio','video'.., which will then lookup at the first matching entry in the media list. perl v5.14.2 2012-06-08 Net::SIP::SDP(3pm)
All times are GMT -4. The time now is 11:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy