exerciese6
Exercise 6. Write a shell script to check that the 'file_path' is exist or not. If file exist check that file is having read permission or not and then display the content of file if file having read permission, If not then display the message "File is read protected". And if file does not exist then display the message "File is not present".
Script: By using if condition we checked by '-e' option first file is exist then if file exists we checked by using '-r' option that the file is having read permission. If the read permission is there for the file then by 'cat' command we displayed the output of the file entered by the username. If the '-r' condition is false then we display a message that file is read protected. And if the '-e' condition is false then it will display message that file is not present.
Output1: If file is present and having read permission as well.
Output2: If file is not present.
Output3: If file is not having read permission.
No comments:
Post a Comment