Shell scripting 2
Question:
Read the user inputs and check for that whether it is available or not ,If it is available print the user inputs are available else print not available , also your output should print after 10 Sec
Answer:
Path="/home/kalam/filename.sh"
echo "User provide path is : $Path"
sleep 10
if [ -e $Path ]
then
echo "file is present in the $Path"
else
echo "File is absent in the given path: $Path"
echo "Please correct the path and rerun the script"
echo "thank you for using this script"
fi
Output:
User provide path is : /home/kalam/filename.sh
file is present in the /home/kalam/filename.sh
Note:
-e is the flag which is used to check for the existence of the file or directory
No comments:
Post a Comment