The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-22-2006
Ygor's Avatar
Ygor Ygor is offline
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,221
Try...
Code:
eg="eg: this is bryan"
w1="this"
w2="bryan"
result=$(echo $eg | awk -v w1="$w1" -v w2="$w2" 'match($0, w1 ".*" w2){
   print substr($0,RSTART+length(w1),RLENGTH-length(w1 w2))}')
echo $result
Reply With Quote