Hi
can anyone tell me why is this code giving error
mode=$1
if [[ $# != 1]] || [[$mode != "find" && $mode != "kill" ]] then
echo "MODES:"
exit 1
fi
Thanks
Hi
can anyone tell me why is this code giving error
mode=$1
if [[ $# != 1]] || [[$mode != "find" && $mode != "kill" ]] then
echo "MODES:"
exit 1
fi
Thanks
I moved "then" to the next line and it got compiled without any error.
Hope this will resolve your problem.
Cheers.
You need to give space before ]] and after [[
if [[ $# != 1 ]] || [[ $mode != "find" && $mode != "kill" ]] then
But I will write like...
if [[ $# -ne 1 || ( $mode != "find" && $mode != "kill" ) ]]; then
tried this too
mode=$1
if [[ $# -ne 1]] || [[ ${mode} -ne "find" && ${mode} -ne "kill" ]] then
echo "MODES:"
fi
In both cases the error is common
Tes[2]: syntax error at line 5 : `${mode}' unexpected
mode=$1
if [ $# -ne 1 ] || [ "${mode}" != "find" -a "${mode}" != "kill" ]; then
echo "MODES:"
fi
Thanks,
Phani Kumar
hi thanks
2nd way the code works..and give output as desired.
1st method compiles but doesnt give desired output.(couldnt figure out why?)
---------- Post updated at 03:58 PM ---------- Previous update was at 03:57 PM ----------
hi moving then to the second line has helped.. thankyou