Good morning ! trying to execute this code but i have an error on if statement . error message : error script_name.sh: line 6: [[0: command not found the problèm is on "if" statement. help please
#!/bin/ksh
jour=$(date +%Y%m%d)
#Control if run is ok or not before sending mail
dir_resultFailure=/transfertCLINK/Share/RESULT_UAT/$jour/FichierFailure/
dir_resultFilteredOut=/transfertCLINK/Share/RESULT_UAT/$jour/FichierFilteredOut/
if [[ `ls $dir_resultFailure | wc -l` -eq 0 ]] && [[`ls $dir_resultFilteredOut | wc -l` -eq 0 ]]
then
echo "repo is empty."
fi
You could have it in following way.
#!/bin/ksh
jour=$(date +%Y%m%d)
#Control if run is ok or not before sending mail
dir_resultFailure="/transfertCLINK/Share/RESULT_UAT/$jour/FichierFailure/"
dir_resultFilteredOut="/transfertCLINK/Share/RESULT_UAT/$jour/FichierFilteredOut/"
if [[ $(ls $dir_resultFailure | wc -l) -eq 0 ]] && [[ $(ls $dir_resultFilteredOut | wc -l) -eq 0 ]]
then
echo "repo is empty."
fi
Improvments/Fixes in OP's attempts:
"
.$(....)
for saving variables values.if
condition was not correct, you should have spaces in between [[
and (
.