Help with Linux in puTTy Please write a shell script called

Help with Linux in puTTy

Please write a shell script called “checkfile” that checks a file provided from the command line by the user to determine whether it is a regular file. If it is a regular file, your script should go further to determine whether it is readable and executable? Your script should display the information on each checking step it makes, such as “The file is a regular file” or “The file is a readable file,” etc.

Please test your script to make sure it displays the information as required;

Solution

checkfile.sh

#!/bin/bash

file_name=$1;

if [ -f $file_name ]; then
   echo \"The file $file_name is a regular file\"
   if [ -x $file_name ]; then
       echo \"The file $file_name is executable\"
       if [ -r $file_name ]; then
           echo \"The file $file_name is readable\"
       else
           echo \"The file $file_name is not readable\"
       fi
   else
       echo \"The file $file_name is not executable\"  
   fi
else
   echo \"The file $file_name is not a regular file\"
fi
          

Help with Linux in puTTy Please write a shell script called “checkfile” that checks a file provided from the command line by the user to determine whether it is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site