Ascalonian
Programmer
I am so lost trying to use the OR operator in my script. I have tried everything and can't seem to get it to work. I am using Cygwin on windows, and my default shell is tcsh (echo $0).
I have tried the following...
This tells me: [: missing ']'
So then I tried this:
Got the same response. So I tried something else
I am getting syntax issues.
How do I write the syntax to use an or statement here?
As an FYI, this regular if statement works fine:
I have tried the following...
Code:
#!/bin/sh
echo "Enter: 1,2 or 3"
read choice
if [$choice -eq "1" -o $choice -eq "2"]; then
echo "Both 1 and 2"
fi
So then I tried this:
Code:
#!/bin/sh
echo "Enter: 1,2 or 3"
read choice
if [$choice -eq "1"] -o [$choice -eq "2"]; then
echo "Both 1 and 2"
fi
Got the same response. So I tried something else
Code:
#!/bin/sh
echo "Enter: 1,2 or 3"
read choice
if [[$choice -eq "1" -o $choice -eq "2"]]; then
echo "Both 1 and 2"
fi
I am getting syntax issues.
How do I write the syntax to use an or statement here?
As an FYI, this regular if statement works fine:
Code:
#!/bin/sh
echo "Enter: 1,2 or 3"
read choice
if [$choice -eq "1"]; then
echo "Got 1"
fi