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
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