FILE=/etc/resolv.conf
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
echo "$FILE does not exist."
fi
#!/bin/bash
if [ -e x.txt ]
then
echo "ok"
else
echo "nok"
fi
if [ -f "myFile.txt" ]; then
echo "File found"
fi
if ! [ -f "myFile.txt" ]; then
echo "File not found"
fi
// or as a bash function
openAnything() {
if [ -f "$@" ]; then // if file exist, open file...
code $@ // add your prefered editor/program
else
open $@ // if file not exist open as directory in finder
fi
}
FILE=/etc/resolv.conf
if [ -f "$FILE" ]; then
echo "$FILE exists."
fi
[ -f /etc/resolv.conf ] && echo "$FILE exists."