LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-28-2004, 09:40 PM   #1
TheRealDeal
Member
 
Registered: Jun 2003
Location: Central Coast, NSW, Australia
Distribution: Gentoo
Posts: 438

Rep: Reputation: 30
Catching first letter.


Hi,

I'm writing a script and am stuck with something which I think is pretty simple but can't get around it.

echo "Please enter the first name of the new user in LOWERCASE."
read firstname
echo "Please enter the last name of the new user in LOWERCASE."
read lastname


What I want to do next without the user having to type in any thing else is get the first initial of the $lastname and have it set to $initial or something.

I've tried using echo $lastname | read -n 1 initial but it doesn't seem to work.


Has anyone got a simple alternative for me?

Thanks alot.
Regs
Craig
 
Old 03-28-2004, 09:50 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Re: Catching first letter.

Quote:
Originally posted by TheRealDeal
I've tried using echo $lastname | read -n 1 initial but it doesn't seem to work.
initial=`echo $lastname | cut -b 1`



Cheers,
Tink

Last edited by Tinkster; 03-28-2004 at 09:51 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
catching signals alaios Programming 3 11-16-2007 06:05 AM
catching a keypress on X MD3 Programming 0 02-14-2005 03:07 PM
catching kernel dumps increment Red Hat 2 10-25-2004 12:33 AM
Catching a Hacker... Shr00mBoXx Linux - Security 14 06-30-2004 10:59 PM
Catching a signal? kalleanka Programming 6 02-12-2004 10:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration