Question

Write a bash shell script called direct.sh. This script will take an arbitrary number of command...

Write a bash shell script called direct.sh. This script will take an arbitrary number of command line arguments. Your script should create directories starting with the first argument, then the second directory inside the first one, and then the next one inside the second one, and so on.

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

#!/bin/bash

# $@ is used to represent all arguments to a script. The following for loop will loop
# over each
for dir in "$@"
do
# Make the directory with each variable and cd into them so that next on is created
# inside it.
mkdir $dir
cd $dir
done

The directory structure has been verified with the tree utility. Screenshots below.

Add a comment
Know the answer?
Add Answer to:
Write a bash shell script called direct.sh. This script will take an arbitrary number of command...
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