echo -n "enter path of directory > ";
read DIRECTORY
echo -n "enter name and path of file 1 > ";
read FILE1
echo -n "enter name and path of file 2 > ";
read FILE2
if [ "$DIRECTORY" -a "$FILE1" -a "$FILE2"]
then
echo "all paths have been entered"
else
echo "not all paths have been entered"
fi
if [ -d $DIRECTORY]
then
echo "$DIRECTORY ok"
else
echo "$DIRECTORY not ok"
fi
if [ -f $FILE1]
then
echo "$FILE1 ok"
else
echo "$FILE1 not ok"
fi
if [ -f $FILE2]
then
echo "$FILE2 ok"
else
echo "$FILE2 not ok"
fi
why doesn't this work?!?!?
i'm using bourne shell and just want the user to enter and directory and two paths and the script to say whether they exist or not. thanks in advanced!
I think you forgot some spaces. if [ -f $FILE] is a syntax error, if [ -f $FILE ] is not. Also, I added some quotes(highlighted for clarity) in places you'll likely need them in order to deal with filenames containing spaces.