temp.txt verify if the file exists:
if [-f temp.txt]verify if the TEMP directory exists, if not create it:
then echo "temp.txt exist."
else echo "temp.txt not exist."
fi
if [-d TEMP];
then echo "TEMP exists."
else mkdir TEMP
fi
invert if and else:
if [! -F temp.txt]
then echo "temp.txt not exist."
else echo "temp.txt exist."
fi if [! TEMP-d] then mkdir TEMP
else echo "TEMP exists."
fi
The following script complete verify the existence of a file passed as an argument:
# / bin / bash #
check that the number of arguments of the script is just a
# if [$ {#}-ne 1] then echo
"Specify the file to verification." Exit 1
fi if [-f $ {1}];
then echo "File exists."
else echo "File does not exist."
fi exit 0
0 comments:
Post a Comment