Create an if-then-else statement to test if a file, represented by the variable $filename, is in fact a file. The statement should also output a notification message which indicates the result of the test.
My goal is to incorporate the above, but by listing the contents of the current directory only and next to each line it states if it's a file or directory [maybe in color].
So far I have gotten this to work.
filename="wp-config.php"
if [ -f "${filename}" ] ; then echo "${filename} is a file" elif [ -d "${filename}" ] ; then echo "${filename} is a directory" fi
Aucun commentaire:
Enregistrer un commentaire