Question

write a bash script that will take one or more directory names as arguments and count...

write a bash script that will take one or more directory names as arguments and count the number of .txt files under each one (that is the number of .txt files in each subdirectory, subdirectories and so on).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Following is the answer:

countf.sh

#!/bin/bash

for var in "$@"
do
echo "In $var :"
ls -lR "$var"/*.txt | wc -l
done

Input: sh countf.sh . ./files

Output:

Add a comment
Know the answer?
Add Answer to:
write a bash script that will take one or more directory names as arguments and count...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT