Extract the data from tag below asssigned the variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract the data from tag below asssigned the variable
# 1  
Old 04-02-2013
Extract the data from tag below asssigned the variable

Sample data file.

Code:
[OfferTable]
UID=12_C_S_12_PrecisionMktg^12_C_S_12_PrecisionMktg_LinkList
NameField=LINK_NAME
ExternalTrackingField=EXTERNAL_TRACKING
CategoryField=LINK_CATEGORY
URLField=LINK_URL

[DataFile]
UID=12_PrecisionMktg^FILTER_12_C_S_12_PrecisionMktg

[Variables]
comma=,
hbx3=&CMP=EMC-C-S-PreMktg-PC-$PRG_NM$
_Names_=hbx1;hbx2;hbx3
hbx2=&email&CMP=EMC-C-S-PreMktg-PC-$PRG_NM$

i want extract the "[DataFile]" below data as assigned as UID

Output needs to be:
Code:
12_PrecisionMktg 
FILTER_12_C_S_12_PrecisionMktg

Please help me
# 2  
Old 04-02-2013
Code:
awk -F"[=^]" '/DataFile/ {getline;print $2;print$3}' file
12_PrecisionMktg
FILTER_12_C_S_12_PrecisionMktg

# 3  
Old 04-02-2013
Thanks lot.. i have one more tag in my file as like
Code:
[SeedDataFile]
UID=12_C_S_12_PrecisionMktg^12_C_S_12_PrecisionMktg_SEEDLIST_Wave2

this is also giving output.
i want exclude this one.. while matching Datefile in awk command..it's matching this tag..
how can exclude this one..
# 4  
Old 04-02-2013
Code:
awk -F"[=^]" '/\[DataFile\]/ {getline;print $2;print $3}' file

# 5  
Old 04-02-2013
Quote:
Originally Posted by Jotne
Code:
awk -F"[=^]" '/\[DataFile\]/ {getline;print $2;print$3}' file
12_PrecisionMktg
FILTER_12_C_S_12_PrecisionMktg

Hey!!!

Check the exact string match. See highlighted.

Cheers,
RangaSmilie
# 6  
Old 04-02-2013
Oh... Great.....Awesome
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a tag with data and replace its data in another tag

Hi I have one file, :16R::GENL :20C::RELA//SET//ABC123456 :22F::XYZYESR :20C::MITI//NETT/QWERTY12345 :16S::GENL :16R::GENL :20C::RELA//SET//XYZ23456 :22F::XYZYESR :16S::GENL The requirement is, if :20C::MITI// is present in any block, then replace the data of :20C::MITI// in... (8 Replies)
Discussion started by: Soumyadip Dutta
8 Replies

2. Shell Programming and Scripting

awk to extract tag and add to each line

In the awk below which executes as is, I am trying to add a condition that will extract the text or value after the FR= for the lines in each line of file1 compared to file2. As is the lines between the two files are either a match, Missing in file 1, or Missing in file2, but I can not add the... (1 Reply)
Discussion started by: cmccabe
1 Replies

3. UNIX for Dummies Questions & Answers

Extract data from a file and store it in a variable

Hi , I have an file like below , cat input.txt 'Pattern2' => 'blahdalskdahdlahldahdlakhdlahdlkajdlkaadasdadadadadadadasda ajlalnalndklandlaksdlkaddd' 'Pattern2' => 'aohaonalkndlanldandlandklasnldnaldnak' ............ ........ ..... Here is what am trying to do , I want to grep for... (3 Replies)
Discussion started by: scott_cog
3 Replies

4. Shell Programming and Scripting

Extract XML tag value from file

Hello, Hope you are doing fine. I have an log file which looks like as follows: Some junk text1 Date: Thu Mar 15 13:38:46 CDT 2012 DATA SENT SUCCESSFULL: Some jun text 2 Date: Thu Mar 15 13:38:46 CDT 2012 DATA SENT SUCCESSFULL: ... (3 Replies)
Discussion started by: srattani
3 Replies

5. Shell Programming and Scripting

Extract TAG name and XPATH from XML file via shellscript

Hi, Here is a sample xml file and expected output. I need to extract the element/tag name (not value) and xpath (sample output.txt). But the main problem is I put here one simple xml file where I can clearly see the number of elements, but in real time I have a xml file which have over 500... (18 Replies)
Discussion started by: BithunC
18 Replies

6. Shell Programming and Scripting

Extract multiple xml tag value into CSV format

Hi All, Need your assistance on another xml tag related issue. I have a xml file as below: <INVOICES> <INVOICE> <BILL> <BILL_NO>1234</BILL_NO> <BILL_DATE>01 JAN 2011</BILL_DATE> </BILL> <NAMEINFO> <NAME>ABC</NAME> </NAMEINFO> </INVOICE> <INVOICE> <BILL> <BILL_NO>5678</BILL_NO>... (12 Replies)
Discussion started by: angshuman
12 Replies

7. Shell Programming and Scripting

extract xml tag based on condition

Hi All, I have a large xml file of invoices. The file looks like below: <INVOICES> <INVOICE> <NAME>Customer A</NAME> <INVOICE_NO>1234</INVOICE_NO> </INVOICE> <INVOICE> <NAME>Customer A</NAME> <INVOICE_NO>2345</INVOICE_NO> </INVOICE> <INVOICE> <NAME>Customer A</NAME>... (9 Replies)
Discussion started by: angshuman
9 Replies

8. Shell Programming and Scripting

how to extract the info in the tag from a xml file

Hi All, Do anyone of you have any idea how to extract each<info> tag to each different file. I have 1000 raw files, which come in every 15 mins.( I am using bash) I have tried my script as below, but it took hours to finish, which is inefficiency. perl -n -e '/^<info>/ and open FH,">file".$n++;... (2 Replies)
Discussion started by: natalie23
2 Replies

9. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

10. Shell Programming and Scripting

Extract value inside <text> tag for a particular condition.

Hi All! I have obtained following output from a tool "pdftohtml" :: So, my input is as under: <text top="246" left="160" width="84" height="16" font="3">Business purpose</text> <text top="260" left="506" width="220" height="16" font="3">giving the right information and new insights... (3 Replies)
Discussion started by: parshant_bvcoe
3 Replies
Login or Register to Ask a Question