I'm trying to write an expression like this one ---> if [ $condition1 ] && [ $condition2 ]
in bash but i keep getting the same error all the times
syntax error near unexpected token `elif'
./leer.sh: line 25: `elif [[ "$($(date +%Y) -eq $ano)" && "$($(date +%m) -lt $mes)" ]]'
That part of the code is:
elif [[ $($(date +%Y) -eq $year) && $($(date +%m) -lt $month) ]]
then
echo "Well done";
There are a couple of thing wrong here:
if
but with elif
fi
$(...)
Do you try to do this?
#!/bin/bash
year=2013
month=11
if [[ $(date +%Y) -eq $year && $(date +%m) -lt $month ]]; then
echo "Well done"
fi
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.