Can someone help me with creating a bash shell script.
I need to create a script that gets a positive number n as an argument.
The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So map_1 contains map_2, map_2 contains map_3 and so forth.
Looks like a homework question, so here's a hint: given the number "n", loop from 1 through n and create a string that represents the directory tree you want. Then use the "-p" option of "mkdir" command to create the directory tree.
Hope that helps,
tyler_durden
______________________________________________
"Only after disaster can we be resurrected."
# n is 1 by default
n=1
# this is a loop where it actually says when n is less then 1 or on do something
while [ $n -le $1 ]
# this part I don't understand
do
dir=map_$n
mkdir "$dir" && cd "$dir" || exit 1
n=$(( $n + 1 ))
done
$1 represents the input parameter(first parameter). So if you supply 4 when running the script, $1 will be 4. In that case, the while loop will be like
while [ 1 -le 4 ]...and then increment 1 by 1..till it reaches 4.