I'm trying to add options to my little safe delete script. For example, I can do ./sdell -s 100 and it will delete files with size above 100 kbs. Anyway, I'm having problems with my safe guard function.
#!/bin/bash
#Purpose = Safe delete
#Created on 20-03-2018
#Version 0.8
#jesus,i'm dumb
#START
##Constants##
dir="/home/cunha/LIXO"
#check to see if the imputs are a files#
for input in "$@"; do
if ! [ -e "$input" ]; then
        echo "Input is NOT a file!"
        exit 1
fi
done
###main###
case $1 in
        -r)     echo "test option -r"
                ;;
        *)      if [[ -f "$dir/$fwe.tar.bz2" ]]; then
                        echo "File already exists."
                        if [[ "$file" -nt "$2" ]]; then
                echo "Removing older file." && rm "$dir"/"$fwe.tar.bz2" && tar -czPf "$fwe.tar.bz2" "$(pwd)" && mv "$fwe.tar.bz2" "$d$
                        fi
                else
                echo "Ziping it and moving." &&  tar -czPf "$fwe.tar.bz2" "$(pwd)" && mv "$fwe.tar.bz2" "$dir"    
                fi
                done
                ;;
esac
The problem is when I call ./sdell -r file1.txt, it says that the input is not a file.
Here is the script without the case, 100% working before having options.
#!/bin/bash
#Purpose = Safe delete
#Created on 20-03-2018
#Version .7
#START
##Constants##
dir="/home/cunha/LIXO"
#check to see if the imputs are a files#
for input in "$@"; do
if ! [ -e "$input" ]; then
        echo "Input is NOT a file!"
       exit 0
fi
done
###main###
##Cycle FOR so the script accepts multiple file inputs##
for file in "$@"; do
fwe="${file%.*}"
#IF the input file already exist in LIXO#
if [[ -f "$dir/$fwe.tar.bz2" ]]; then
        echo "File already exists."
#IF the input file is newer than the file thats already in LIXO#
        if [[ "$file" -nt "$2" ]]; then
                echo "Removing older file." && rm "$dir"/"$fwe.tar.bz2" && tar -czPf "$fwe.tar.bz2" "$(pwd)" && mv "$fwe.tar.bz2" "$d$
        fi
else
echo "Ziping it and moving." &&  tar -czPf "$fwe.tar.bz2" "$(pwd)" && mv "$fwe.tar.bz2" "$dir"
fi
done
 
     
    