LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-03-2009, 02:44 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
using if statement


hi all.....

ans='To exit'
echo $ans
if [ $ans == 'To exit' ]
then
echo hello
fi


this is my script when i execute this it is giving following error

To exit
new: line 3: [: too many arguments

anyone please help me...
thanks in advance...
 
Old 06-03-2009, 02:51 AM   #2
rikxik
Member
 
Registered: Dec 2007
Posts: 88

Rep: Reputation: 19
Should be:

Code:
ans='To exit'
echo $ans
if [ "$ans" == 'To exit' ]
then
echo hello
fi
 
Old 06-03-2009, 02:54 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Thank u so much....
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with if statement in a find -exec statement romsieze Programming 2 10-02-2008 01:38 AM
for statement WT* malikah Programming 7 07-11-2008 03:15 AM
if statement malikah Programming 2 07-10-2008 11:06 PM
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 09:05 PM
the FOR statement (C) sk84blood813 Programming 3 12-09-2004 09:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:08 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration