Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Zip the files if count is more than 0 and send a mail

$
0
0
All,

I am new to shell scripting and trying to get the count of files that starts with error and with extension .out, if the count is greater than 0 and zip the file and send an email with the content of error.out file, here is my script
Code:

cd /temp
testcount =$('find . -name '*.out' -print | wc -l')
echo $testcount
if [[ $testcount -ne 0 ]]
then
zip error_log.zip *.out
cat error_*.out | mailx -s "for testing" username@doamin.com
exit 1
else
exit 0
fi

Moderator's Comments:
code tags, please

when I tried to execute above script I am getting below error

./test.ksh: line 2: find . -name *.out -print | wc -l: command not found
./test.ksh: line 2: testcount: command not found


Can someone please tell me what is wrong with this script?

Viewing all articles
Browse latest Browse all 16232

Trending Articles