Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-08-2007, 08:13 PM   #1
LQ Newbie
Registered: Oct 2007
Posts: 8

Rep: Reputation: 0
Angry more help with if, else

I changed the -eq to "=", but I am still getting the same error:


I am trying to do a simple file, but I cannot get it to work. Can you please let me know what I may be doing wrong. I am typing this using pico.


echo -n "What is your last name?>"
read text
echo -n "Are you male or female?>"
read sex
if ($sex = "male"); then
echo "Hello Mr. $text"
echo "Hello Ms. $text"

This is the output I receive:

What is your last name?>mmmmmmmm
Are you male or female?>male
./morf.test: line 7: male: command not found
Hello Ms. mmmmmmmm
Old 10-08-2007, 08:28 PM   #2
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I have not checked every line of code, but a test statement goes like this:

if [ $sex = "male" ]

Note that "[" is a synonym for "test", and that the space before and after is required
Old 10-08-2007, 08:37 PM   #3
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130

echo -n "What is your last name?>"
read text
echo -n "Are you male or female?>"
read sex
if [ $sex = "male" ]; then
echo "Hello Mr. $text"
echo "Hello Ms. $text"

Exactly as pixellany said, in short.

Last edited by jay73; 10-08-2007 at 08:42 PM.


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 Off
HTML code is Off

All times are GMT -5. The time now is 02:25 PM.

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