Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

sed - extract text from xml file

Shell Programming and Scripting


Closed    
 
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: 4 December 2016, 11:37 AM EST
Location: Amsterdam
Posts: 11,101
Thanks: 440
Thanked 3,108 Times in 2,749 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

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 08:02 PM
extract blocks of text from a file cajunfries Shell Programming and Scripting 7 05-18-2009 12:41 PM
c program to extract text between two delimiters from some text file kukretiabhi13 Programming 7 12-03-2008 06:29 PM
How to extract text from xml file chrisf Shell Programming and Scripting 3 09-01-2007 03:25 PM
How to extract data from a text file negixx Shell Programming and Scripting 1 07-19-2005 10:30 PM



All times are GMT -4. The time now is 02:22 PM.