I want an if statement in my bash script to check if a file is empty. I've tried
if [ -s <stuff here> ] ;
if [ -z <stuff here> ] ;
but they don't seem to work. Is there something I can do with grep that will make it work? THe code below ALWAYS seems to return the "There are no URLS.." even if there are
if [ -s $DLBASKET];
cat $DLBASKET | (
while read url ; do
# First, check the cache if the file has been already downloaded
if grep -i $(basename $url) "$CACHEFILE" >/dev/null 2>&1; then
echo "$DATETIME File exists in cache. Already downloaded - Skipping: $url"
echo $url >> $LOGFILE
echo "$DATETIME Starting: $url"
if [ $(expr match "$url" '[rapidshare.com]') = 1 ] ; then
# If it is a Rapidshare.com link, load the RS cookie
echo "RAPIDSHARE LINK"
wget -c -t 1 --directory-prefix=$DLDIR --load-cookies $RSCOOKIE $url
wget -c -t 1 --directory-prefix=$DLDIR $url
echo "$DATETIME Finished: $url"
echo $DATETIME $url >> $LOGFILE
echo $url >> $CACHEFILE
echo "All Files have been downloaded, clearing Download Basket"
echo "There are no URLS in $DLBASKET"