sed - extract text from xml file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

sed - extract text from xml file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 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 02-09-2012
Scrutinizer's Avatar
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 16 September 2014, 12:46 AM EDT
Location: Amsterdam
Posts: 9,443
Thanks: 278
Thanked 2,380 Times in 2,134 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 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 Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:53 AM.