Reputation:
so i am doing a shell script and am trying to figure out how to do this safe guard function:
if ! [[ -e "$@" ]]; then
echo"Not a file!"
exit 0
fi
my ideia is to check every input for file. so when i call the script: ./scriptname file1.txt file2.tar NOTfile4 it will output NOT a file
Upvotes: 0
Views: 63
Reputation:
thanks guys! did the loop and it worked. heres what i did if anyone who has the same problem:
for input in "$@"; do
if ! [ -e "$input" ]; then
echo "Not a file!"
exit 0
fi
done
Upvotes: 1