nick34992
2/22/2017 - 2:41 PM

Bash: if, then, else, echo: Check for Presence of any File in a Given Path

Bash: if, then, else, echo: Check for Presence of any File in a Given Path

#!/bin/bash

file_path="/etc/passwd"

if [ -e $file_path ]; then
echo "Directory contains file(s)";
else
echo "Directory does not contain a file.";
fi