Question: #!/bin/bash for file in $@; do if [[ -r $file && -w $file && -x $file ]] then count=$((count+1)) fi done echo Of the $#

#!/bin/bash

for file in $@; do

if [[ -r $file && -w $file && -x $file ]]

then count=$((count+1))

fi

done

echo Of the $# files entered, $count were r/w/x

Using Linux scripting write a program which receives a directory name as its only parameter. If it does not receive a parameter or receives more than one, output an error. Otherwise, iterate through the contents of the directory and count and output the number of items in the directory that are regular files, that are directories, and that are links. To indicate the items in the directory in your for loop, use either $1/* or `ls $1/*` as the list to iterate over. Also output the total number of items found in the directory. Run this script on several directories like /etc, /bin and ~, ~/new and ~/scripts.

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!