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 > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: Awk Command
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #18 (permalink)  
Old 01-02-2009
TheEngineer TheEngineer is offline
Registered User
  
 

Join Date: Apr 2006
Location: Iraq
Posts: 36
Hello kazazza

AWK need a mapping in order to read normal shell variables, you'd rather need to re-form your command as below to get the desired result:

title="Mr"
echo "Please Enter your name: "
read name
echo $name | awk -v awk_title=$title '{print "hello " awk_title ". " $NF}'

or you can assign the title variable from within AWK
echo "Please Enter your name: "
read name
echo $name | awk BEGIN '{title="Mr"} {print "Hello " title ". " $NF}'

Last edited by TheEngineer; 01-06-2009 at 03:44 PM..