Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

sed - extract text from xml file

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-09-2012
gioni gioni is offline
Registered User
 
Join Date: Feb 2012
Last Activity: 12 September 2012, 1:31 PM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sed - extract text from xml file

hi,

please help, i have an xml file, e.g:

...
<tag> test text
asdas="${abc}"
xvxvbs:asdas${222}sdad

asasa="${aa_bb_22}"
</tag>
...

i want to extract all "${...}", e.g:
${abc}
${222}
${aa_bb_22}

thank you.
Sponsored Links
    #2  
Old Unix and Linux 02-09-2012
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 28 May 2015, 1:03 AM EDT
Location: Amsterdam
Posts: 10,216
Thanks: 334
Thanked 2,697 Times in 2,413 Posts
Does you grep have a -o option? ( man grep | grep '^[ \t]*\-o' ) then you can try this:

Code:
grep -o '${[^}]*}' infile

Sponsored Links
    #3  
Old Unix and Linux 02-10-2012
tarun_agrawal tarun_agrawal is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 29 May 2012, 10:09 PM EDT
Posts: 87
Thanks: 0
Thanked 16 Times in 15 Posts
try this


Code:
 egrep -o '\$\{[^ ]+\}' filename

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
extract text from a file loperam Shell Programming and Scripting 2 06-18-2010 07:02 PM
extract blocks of text from a file cajunfries Shell Programming and Scripting 7 05-18-2009 11:41 AM
c program to extract text between two delimiters from some text file kukretiabhi13 Programming 7 12-03-2008 05:29 PM
How to extract text from xml file chrisf Shell Programming and Scripting 3 09-01-2007 02:25 PM
How to extract data from a text file negixx Shell Programming and Scripting 1 07-19-2005 09:30 PM



All times are GMT -4. The time now is 10:05 AM.