The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-20-2007
rakeshou rakeshou is offline
Registered User
  
 

Join Date: May 2007
Posts: 75
Wink Extract string between <>

hi,

I want a simple way to extract string between two angle brackets <>

the text looks like

echo "###Usage: $0 <database1> <database2>"

what I want is two variables DB1=database1 and DB2=database2

What I am doing looks clumsy to me

Code:
DB1=`echo $line | sed 's/"//g' | sed 's/>//g' | awk -F"<" '{print $2}'`
DB2=`echo $line | sed 's/"//g' | sed 's/>//g' | awk -F"<" '{print $3}'`
thanks in advance