Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help with Linux in puTTy Please write a shell script called “ checkfile ” that c

ID: 3922014 • Letter: H

Question

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;

Explanation / Answer

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
          

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote