You are not logged in.
The following if statement checks if the file exists!
# script checks
if [[ -d $1 ]]
then
echo "Script $1 exists!"
else
echo "Script $1 does not exist!"
fi
However, regardless if the file exists. It says it exists, no matter what. I've always found variable and file checks in if statements to rarely work.
System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)
Offline
First -d tests whether the file exists and is a directory; is that what you really want?
Second, I'd wager properly quoting around $1 will solve your perceived problem. To see why run the following:
if [[ -d ]]; then
echo first
fi
if [[ -d "" ]]; then
echo second
fi
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline