how can i extract text section via grep


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how can i extract text section via grep
# 8  
Old 07-02-2009
Quote:
Originally Posted by meny
thanks folks but it seems the it just opens the file (as cat).

hoped it will retrieve the row's number.

thanks...
care to elaborate with an example of input/output?
# 9  
Old 07-03-2009
hi there- more input

hi mate,

below i paste the exact section that i need for my bash script.
so i need to isolate it in order to display it or extract some text from it.

note that some of the input is unique for this module (nm="db") but not for the entire configuration file- once i will isolate this module it will be much easier to extract the relevant text.

the section that i need to isolate from the file content:

<Module nm="db" service="DB" element="Physical connection" desc="Configurations for Database connection - server, s
chema, connections " exp="Production">
<ParamSubList nm="db" service="DB" element="Physical connection" desc="Configurations for Database connection - s
erver, schema, connections " exp="Internal" sectionType="" keyDesc="" valDesc="" paramsTp="None">
<Param key="username" v="clients_46_sp6" machine="" site="" tp="string" desc="DB Username" exp="CustomerSupport
" hot="false" cat="Basic" layer="Installation" mandatory="false" id="8954" service="General" element="Database" />
<Param key="password" v="clients_46_sp6" machine="" site="" tp="string" desc="DB Password" exp="CustomerSupport
" hot="false" cat="Basic" layer="Installation" mandatory="false" id="8955" service="General" element="Database" />
<Param key="host" v="qa158" machine="" site="" tp="string" desc="Service name of the local database, as configu
red in the TNS names .ora file" exp="CustomerSupport" hot="false" cat="Basic" layer="Installation" mandatory="false"
id="8956" service="General" element="Database" />
<Param key="connections_amount" v="3" machine="" site="" tp="string" desc="" exp="CustomerSupport" hot="false"
cat="None" layer="Installation" mandatory="false" id="0" service="DB" element="Physical connection" />
<Param key="override_language" v="10" machine="" site="" tp="string" desc="System preferred language" exp="Cust
omerSupport" hot="false" cat="Basic" layer="Installation" mandatory="false" id="8953" service="General" element="Loca
lization" />
<Param key="system_language_string" v="SYSTEM PREFERRED LANGUAGE" machine="" site="" tp="string" desc="Language
description for system preferred language" exp="CustomerSupport" hot="false" cat="Basic" layer="Installation" mandat
ory="false" id="0" service="DB" element="Physical connection" />
<Param key="repository_debug_mode" v="no" machine="" site="" tp="string" desc="This parameter is used to show a
message if a missing Repository entry is found" exp="CustomerSupport" hot="false" cat="Basic" layer="Installation" m
andatory="false" id="18791" service="General" element="Database" />
<Param key="empty_string" v="MISSING REPOSITORY" machine="" site="" tp="string" desc="" exp="Internal" hot="fal
se" cat="None" layer="Installation" mandatory="false" id="0" service="DB" element="Physical connection" />
<Param key="use_oci_corba" v="no" machine="" site="" tp="string" desc="" exp="CustomerSupport" hot="false" cat=
"None" layer="None" mandatory="false" id="18903" service="General" element="Database" />
<Param key="connection_expiration" v="900" machine="" site="" tp="string" desc="refresh time for DB connection"
exp="Internal" hot="false" cat="None" layer="None" mandatory="false" id="0" service="DB" element="Physical connectio
n" />
<Param key="take_db_connection_timeout_sec" v="4" machine="" site="" tp="string" desc="Enables timeout in secon
ds when waiting for free db connections. Default is 0. 0-wait forever, 1 and more - seconds to wait for a free db con
nection" exp="Internal" hot="false" cat="None" layer="Installation" mandatory="false" id="0" service="General" elemen
t="Physical connection" />
<Param key="extended_log_level" v="0" machine="" site="" tp="string" desc="Enables extended debug logging. Defa
ult is 0. 0-Disabled, 1-Basic, 2-Verbose, 3-Full" exp="Internal" hot="false" cat="None" layer="Installation" mandator
y="false" id="0" service="General" element="Physical connection" />
<Param key="latency_warning_threshold" v="22000" machine="" site="" tp="string" desc="Sets the max latency in D
B calls (milliseconds), after which a warning is logged" exp="Internal" hot="false" cat="None" layer="None" mandatory
="false" id="0" service="DB" element="Physical connection" />
</ParamSubList>
</Module>

thanks dude...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

How to Grep of by section?

I have a script that outputs this as a file John Smith ---------------- memberOf: example1;sampletest;test memberOf: example2;sampletest;test memberOf: example3;sampletest;test memberOf: example4;sampletest;test A Member of 4 Groups Sally Smith ---------------- memberOf:... (4 Replies)
Discussion started by: ajetangay
4 Replies

3. Shell Programming and Scripting

Script extract text from txt file with grep

All, I require a script that grabs some text from the gitHub API and will grep (or other function) for a string a characters that starts with (") quotes followed by two letters, may contain a pipe |, and ending with ) . What i have so far is below but it's not returning anything. ... (4 Replies)
Discussion started by: ChocoTaco
4 Replies

4. Shell Programming and Scripting

Grep text and see all section

Hello I am looking for a way to look in files and to grep text and see the all section of the text ! Sharon123 deed 10000 class 360 ! sharon456 2000 deed ! Sharon789 live 3000 ! To grep "deed "an see the all section (5 Replies)
Discussion started by: sharong
5 Replies

5. Shell Programming and Scripting

Extract record from file based on section.

input file output file (1 Reply)
Discussion started by: lathigara
1 Replies

6. Shell Programming and Scripting

Extracting text from within a section of text using AWK

I have a command which returns the below output. How can I write a script to extract mainhost and secondhost from this output and put it into an array? I may sometimes have more hosts like thirdhost. I am redirecting this output to a variable. So I guess there should be a awk or sed command to... (7 Replies)
Discussion started by: heykiran
7 Replies

7. Shell Programming and Scripting

Need help please with Grep/Sed command to extract text and numbers from a file

Hello All, I need to extract lines from a file that contains ALPHANUMERIC and the length of Alphanumeric is set to 16. I have pasted the sample of the lines from the text file that I have created. My problem is that sometimes 16 appears in other part of the line. I'm only interested to... (14 Replies)
Discussion started by: mnassiri
14 Replies

8. Shell Programming and Scripting

Extract section of file based on word in section

I have a list of Servers in no particular order as follows: virtualMachines="IIBSBS IIBVICDMS01 IIBVICMA01"And I am generating some output from a pre-existing script that gives me the following (this is a sample output selection). 9/17/2010 8:00:05 PM: Normal backup using VDRBACKUPS... (2 Replies)
Discussion started by: jelloir
2 Replies

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

10. Shell Programming and Scripting

Search and extract by section from configuration

Hi, I understand either AWK or SED can do this, but I not sure how to extract the following configuration in section. Meaning when I need to find code with " ip helper-address 192.168.11.2" , it would start from "interface Serial0/0" and "interface FastEthernet0/1". Only displaying both section... (2 Replies)
Discussion started by: haphazard
2 Replies
Login or Register to Ask a Question