Write a shell script checkpath that extracts each directory from the user's PATH and ensures that the directory exists and is readable. Report either error condition or confirm that the directory is correctly configured. Hint: directories in the PATH are separated by a colon (:).

What will be an ideal response?


for directory in $( echo $PATH | sed 's/:/ /g')
do
if [ ! -d "$directory" ] ; then
echo "Warning: PATH directory $directory doesn't exist"
elif [ ! -r "$directory" ] ; then
echo "Warning: PATH directory $directory isn't readable"
else
echo "Checked directory $directory"
fi
done

exit 0

Computer Science & Information Technology

You might also like to view...

Which operation does not take place in the following example?

int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; a. Implicit conversion. b. Promotion. c. Explicit conversion. d. Truncation.

Computer Science & Information Technology

Frequently used content or objects can be saved as what?

A) Building blocks B) Templates C) Office objects D) Building objects

Computer Science & Information Technology

Answer the following statement(s) true (T) or false (F)

By the 1970s, electronic crimes were increasing, especially in the financial sector.

Computer Science & Information Technology

Which of the following Boolean logic operators would find all of the search criteria except what was listed?

A) NOT B) OR C) AND D) ALMOST

Computer Science & Information Technology