The UNIX and Linux Forums  


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 -->
  #22 (permalink)  
Old 01-08-2009
dajon dajon is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
I don't know why you want first and last in the same string but here's an answer (there are many possible methods).

There are significant benefits to keeping the first and last separate (ie, if the person is a Jr, Sr. III etc) or has a hyphenated name or multiple sirnames...

#!/usr/bin/sh
echo "Enter your full name (i.e. first and last name)"
read name
echo "Hello Mr. `echo $name | awk '{print $NF}'`"

Good luck....