Sponsored Content
Top Forums UNIX for Dummies Questions & Answers extract text between two strings exclusive Post 302309634 by the1armedcoder on Wednesday 22nd of April 2009 12:12:51 PM
Old 04-22-2009
extract text between two strings exclusive

Hi,

I'm trying to retrieve text between two strings excluding the two strings.

So for example I have the following input:

[phone1]
type=friend
username=phone1
secret=password
host=dynamic
dtmfmode=rfc2833
mailbox=9664
context=sip
insecure=very
canreinvite=no
nat=yes
realm=192.168.1.122
callerid="Phone 1" <0001>


I want to get the value of "secret". I have tried a few things such as

Code:
sed -n '/secret=/,/host/p'  and
awk '/secret=/, $NF ~ /host/'

but these return the search strings also:
secret=password
host=dynamic

I want to get just "password" for the output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using AWK how to extract text between two same strings

I have a file like: myfile.txt it is easy to learn awk and begin awk scripting and awk has got many features awk is a powerful text processing tool Now i want to get the text between first awk and immediate awk not the third awk . How to get it ? its urgent pls help me and file is unevenly... (2 Replies)
Discussion started by: santosh1234
2 Replies

2. Shell Programming and Scripting

using awk to extract text between two constant strings

Hi, I have a file from which i need to extract data between two constant strings. The data looks like this : Line 1 SUN> read db @cmpd unit 60 Line 2 Parameter: CMPD -> "C00071" Line 3 Line 4 SUN> generate Line 5 tabint>ERROR: (Variable data) The data i need to extract is... (11 Replies)
Discussion started by: mjoshi
11 Replies

3. UNIX for Dummies Questions & Answers

Using awk/sed to extract text between Strings

Dear Unix Gurus, I've got a data file with a few hundred lines (see truncated sample)... BEGIN_SCAN1 TASK_NAME=LA48 PDD Profiles PROGRAM=ArrayScan 1.00 21.220E+00 2.00 21.280E+00 END_DATA END_SCAN1 BEGIN_SCAN2 TASK_NAME=LA48 PDD Profiles 194.00 2.1870E+00 ... (5 Replies)
Discussion started by: tintin72
5 Replies

4. Shell Programming and Scripting

AWK: How to extract text lines between two strings

Hi. I have a text test1.txt file like:Receipt Line1 Line2 Line3 End Receipt Line4 Line5 Line6 Canceled Receipt Line7 Line8 Line9 End (9 Replies)
Discussion started by: TQ3
9 Replies

5. UNIX for Advanced & Expert Users

bash/grep/awk/sed: How to extract every appearance of text between two specific strings

I have a text wich looks like this: clid=2 cid=6 client_database_id=35 client_nickname=Peter client_type=0|clid=3 cid=22 client_database_id=57 client_nickname=Paul client_type=0|clid=5 cid=22 client_database_id=7 client_nickname=Mary client_type=0|clid=6 cid=22 client_database_id=6... (3 Replies)
Discussion started by: Pioneer1976
3 Replies

6. Shell Programming and Scripting

How to Extract text between two strings?

Hi, I want to extract some text between two strings in a line i am using following command i.e; awk '/-string1/,/-string2/' filename contents of file is--- line1 line2 aaa -bbb -ccc -string1 c,d,e -string2 line4 but it is showing complete line which is having searched strings. aaa... (19 Replies)
Discussion started by: emresearch
19 Replies

7. Shell Programming and Scripting

Extract text between two strings

Hi I have something like this: EXAMPLE 1 CREATE UNIQUE INDEX "STRING_1"."STRING_2" ON "BOSNI_CAB_EVENTO" ("CD_EVENTO" , "CD_EJECUCION" ) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 5242880 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "DB1000_INDICES_512K"... (4 Replies)
Discussion started by: chrispaz81
4 Replies

8. Shell Programming and Scripting

Extract text between two strings

Hi, I have a text like these: ECHO "BEGGINING THE SHELL....." MV FILE1 > FILE2 UNIQ_ID=${1} PARTITION_1=`${PL}/Q${CON}.KSH "SELECT ....." PARTITION_2=`${PL}/Q${CON}.KSH "SELECT ........" ${PL}/Q${CON}.KSH "CREATE ...." IF .... ....... I would like to extract only text that only... (4 Replies)
Discussion started by: mierdatuti
4 Replies

9. UNIX for Dummies Questions & Answers

Issue when using egrep to extract strings (too many strings)

Dear all, I have a data like below (n of rows=400,000) and I want to extract the rows with certain strings. I use code below. It works if there is not too many strings for example n of strings <5000. while I have 90,000 strings to extract. If I use the egrep code below, I will get error: ... (3 Replies)
Discussion started by: forevertl
3 Replies

10. Shell Programming and Scripting

Need grep regex to extract multiline text between two strings

I have a file conatining the below: --- 10.9.16.116: /tmp/5835113081224811756.jar: hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb /tmp/4603745991442278706.jar: hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb 10.9.14.126: /tmp/conf/extra/httpd-ssl.conf: hash:... (1 Reply)
Discussion started by: mohtashims
1 Replies
Smokeping_probes_Radius(3)					     SmokePing						Smokeping_probes_Radius(3)

NAME
Smokeping::probes::Radius - a RADIUS authentication probe for SmokePing OVERVIEW
Measures RADIUS authentication latency for SmokePing SYNOPSIS
*** Probes *** +Radius forks = 5 offset = 50% passwordfile = /some/place/secret secretfile = /another/place/secret step = 300 # The following variables can be overridden in each target section allowreject = true mininterval = 1 nas_ip_address = 10.1.2.3 password = test-password pings = 5 port = 1645 secret = test-secret timeout = 5 username = test-user # mandatory # [...] *** Targets *** probe = Radius # if this should be the default probe # [...] + mytarget # probe = Radius # if the default probe is something else host = my.host allowreject = true mininterval = 1 nas_ip_address = 10.1.2.3 password = test-password pings = 5 port = 1645 secret = test-secret timeout = 5 username = test-user # mandatory DESCRIPTION
This probe measures RADIUS (RFC 2865) authentication latency for SmokePing. The username to be tested is specified in either the probe-specific or the target-specific variable `username', with the target-specific one overriding the probe-specific one. The password can be specified either (in order of precedence, with the latter overriding the former) in the probe-specific variable `password', in an external file or in the target-specific variable `password'. The location of this file is given in the probe-specific variable `passwordfile'. See Smokeping::probes::passwordchecker(3pm) for the format of this file (summary: colon-separated triplets of the form `<host>:<username>:<password>') The RADIUS protocol requires a shared secret between the server and the client. This secret can be specified either (in order of precedence, with the latter overriding the former) in the probe-specific variable `secret', in an external file or in the target-specific variable `secret'. This external file is located by the probe-specific variable `secretfile', and it should contain whitespace-separated pairs of the form `<host> <secret>'. Comments and blank lines are OK. If the optional probe-specific variable `nas_ip_address' is specified, its value is inserted into the authentication requests as the `NAS-IP-Address' RADIUS attribute. The probe tries to be nice to the server and does not send authentication requests more frequently than once every X seconds, where X is the value of the target-specific "min_interval" variable (1 by default). VARIABLES
Supported probe-specific variables: forks Run this many concurrent processes at maximum Example value: 5 Default value: 5 offset If you run many probes concurrently you may want to prevent them from hitting your network all at the same time. Using the probe- specific offset parameter you can change the point in time when each probe will be run. Offset is specified in % of total interval, or alternatively as 'random', and the offset from the 'General' section is used if nothing is specified here. Note that this does NOT influence the rrds itself, it is just a matter of when data acqusition is initiated. (This variable is only applicable if the variable 'concurrentprobes' is set in the 'General' section.) Example value: 50% passwordfile Location of the file containing usernames and passwords. Example value: /some/place/secret secretfile A file containing the RADIUS shared secrets for the targets. It should contain whitespace-separated pairs of the form `<host> <secret>'. Comments and blank lines are OK. Example value: /another/place/secret step Duration of the base interval that this probe should use, if different from the one specified in the 'Database' section. Note that the step in the RRD files is fixed when they are originally generated, and if you change the step parameter afterwards, you'll have to delete the old RRD files or somehow convert them. (This variable is only applicable if the variable 'concurrentprobes' is set in the 'General' section.) Example value: 300 Supported target-specific variables: allowreject Treat "reject" responses as OK Example value: true mininterval The minimum interval between each authentication request sent, in (possibly fractional) seconds. Default value: 1 nas_ip_address The NAS-IP-Address RADIUS attribute for the authentication requests. Not needed everywhere. Example value: 10.1.2.3 password The password for the user, if not present in the password file. Example value: test-password pings How many pings should be sent to each target, if different from the global value specified in the Database section. Note that the number of pings in the RRD files is fixed when they are originally generated, and if you change this parameter afterwards, you'll have to delete the old RRD files or somehow convert them. Example value: 5 port The RADIUS port to be used Example value: 1645 secret The RADIUS shared secret for the target, if not present in the secrets file. Example value: test-secret timeout Timeout in seconds for the RADIUS queries. Default value: 5 username The username to be tested. Example value: test-user This setting is mandatory. AUTHORS
Niko Tyni <ntyni@iki.fi> BUGS
There should be a more general way of specifying RADIUS attributes. 2.6.8 2013-03-17 Smokeping_probes_Radius(3)
All times are GMT -4. The time now is 10:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy