This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Bash - IF Statement


briglass111 wrote on Tuesday, October 27, 2009 3:02 PM:

> I am trying to write an IF Statement in Bash, but I am having issues.
It
> doesn't like the following format:
> 
> echo "yes or no?"
> read T
> 
> if ["$T"="y"];
> then
>         echo "YES"
> fi
> 
> .............. It also doesn't like the following alternatives:
> 
> if [$T="y"];
> if ["$T"=="y"];
> if [$T=="y"];
> if "$T"="y";
> if [["$T"="y"]];
> 
> etc..
> 
> It says:
> y=y: command not found
> 
> Ideas?

You need to add some whitespace so bash can distinguish commands and
arguments:

$ if [ "$T" = "y" ];
then
  echo "YES";
fi
YES

BTW, this is not a Cygwin-specific question :)
-- 
Bryan Thrall
FlightSafety International
bryan.thrall@flightsafety.com

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]