I'm making a program, lab5, to test if the argument is a directory or a file. when I run the program with "bash lab5", I get "unary operator expected on line 3 and 5" What is the problem? Thanks!
#!/bin/bash
if test "$1" -d
then
echo "This is a directory"
elif test "$1" -f
then
echo "This is a file"
else
echo "This is neither a file or a directory"
fi
Aucun commentaire:
Enregistrer un commentaire