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



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with output of find command being input to basename command... new_learner UNIX for Dummies Questions & Answers 2 12-14-2008 02:56 AM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 01:29 PM
assign a command line argument and a unix command to awk variables sweta_doshi Shell Programming and Scripting 0 08-08-2008 06:54 AM
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl SuSE 5 07-30-2007 08:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 12-28-2008
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,947
Quote:
Originally Posted by kazazza View Post
The only reason im using awk is because i was advised that was the best way to do this..... Is there another easier way??
as allready mentioned, the "cut" command is easy to use. and the use of 2 variables, as pludi described, is also very easy. if you have problems to understand specific things, just ask...
  #9 (permalink)  
Old 12-29-2008
krishmaths krishmaths is offline
Registered User
  
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 191
Your approach is right. Just needs a little bit of tweaking in the awk syntax.

Code:
echo "Please enter your full name:"
read name
echo $name | awk '{print"Hello Mr." $2}'
  #10 (permalink)  
Old 12-29-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Originally Posted by krishmaths View Post
Your approach is right. Just needs a little bit of tweaking in the awk syntax.

Code:
echo "Please enter your full name:"
read name
echo $name | awk '{print"Hello Mr." $2}'
that should be $0 instead of $2
  #11 (permalink)  
Old 12-29-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Originally Posted by matrixmadhan View Post
that should be $0 instead of $2
My bad !

Last name is needed by OP. So, $2 should do good and not $0. Sorry.
  #12 (permalink)  
Old 12-30-2008
Gayucvns Gayucvns is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 10
Hi,

the awk command is very useful to print the last name. only the syntax matters. Jst try with this
echo $name | awk '{print "Hello Mr." $2}'
  #13 (permalink)  
Old 12-30-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Originally Posted by Gayucvns View Post
Hi,

the awk command is very useful to print the last name. only the syntax matters. Jst try with this
echo $name | awk '{print "Hello Mr." $2}'
and that is what [ krishmaths ] posted already
  #14 (permalink)  
Old 12-30-2008
kazazza kazazza is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 9
The 'read first last' is a good idea but no good if the user has a middle name. And i cant say 'read first middle last' because it wont work if the user doesn't have a middle name. Thanks for any suggestions.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0