Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#!/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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago