Question: #!/bin/bash #Set variable inpArg= #check command line argument is not passed if [ $# -eq 0 ] then #Print message echo No command line arguments

#!/bin/bash

#Set variable

inpArg=""

#check command line argument is not passed

if [ $# -eq 0 ]

then

#Print message

echo "No command line arguments supplied"

#Prompt for input

echo "Enter input:"

#Read input

read -r inpArg

#If command line argument supplied

else

#Set argument

inpArg=$1

#end of if

fi

#Check input is directory

if [[ -d $inpArg ]]; then

echo "$inpArg is a directory"

#Check input is a file

elif [[ -f $inpArg ]]; then

echo "$inpArg is a file"

#check input is a symbolic link

elif [[ -L "$inpArg" ]]; then

echo "$inpArg is a symlink "

#If input is not valid

else

#Print message

echo "$inpArg is not valid"

#Exit

exit 1

Rewrite so that instead of checking an individual file the user specifies the program checks an entire directory. As the program tests each file, it should both print the results to the screen and simultaneously to a file called Filetypes_in_. The program should use a loop so that after each run, the user is prompted again for a directory name to process, or can enter Q or q to quit. Constraints: The program must successfully detect whether the value entered is a directory -- and process it -- or another type of file. If the value entered is not a directory the user should be informed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!