I have a simple bash script that is part of the embedded web application that I developed.
The goal is to automate the removal of image thumbnails when the user image has been deleted.
script writes some basic status information to a file /var/log/images.log
#!/bin/bash
cd $thumbpath
filecount=0
find . -type f | while read file
do
if [ ! -f "$imagepath/$file" ]
then
filecount=$[$filecount+1]
rm -f "$file"
fi
done
echo `date`: $filecount extraneous thumbs removed>>/var/log/images.log
While the script correctly removes the thumbs, it incorrectly displays the number of fingers removed, it always shows 0.
For example, only by manually creating several orphan sketches, and then running my script, manually deleted big blue ones are deleted, but the log shows:
Thu Jun 9 23:30:12 BST 2011: extraneous thumbs removed
What am I doing wrong that stops $ filecounter from showing a non-zero number when files are deleted .
bash script, , , 0, 1:
#!/bin/bash
count=0
echo $count
count=$[$count+1]
echo $count
Edit:
,
$ x=3
$ x=$[$x+1]
$ echo $x
4
... , script?
:
count=0
echo Initial Value $count
for i in `seq 1 5`
do
count=$[$count+1]
echo $count
done
echo Final Value $count
Initial Value 0
1
2
3
4
5
Final Value 5
count=$[$count+1] count=$((count+1)), script.