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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started