Hi, please help me with this small script
#!/bin/sh
curdir=`pwd`
n20=$curdir'/n20/'
msat=$curdir'/n20/msat/'
if [ ! -d $n20 ]
then
mkdir $n20
fi
if [ ! -d $msat ]
then
mkdir $msat
fi
for a in 30 40 50 60 70 80
do
$aa=$msat'a'$a
mkdir $aa
done
The ouput is
I don't understand what I am missing.
When I replace "mkdir $aa" with "echo $aa". I get the output like this:
Why there is 'not found' here? How should I correct it? Could you please explain for me?
Try this for last for loop should be
for a in 30 40 50 60 70 80
do
aa=${msat}a${a}
mkdir $aa
done
The $aa should be aa only
The same error as mine.
This will create the folder with name "aa". I want to create folder a30, a40,...
#!/bin/ksh
curdir=`pwd`
n20=$curdir/n20
msat=$curdir/n20/msat
if [ ! -d "$n20" ]
then
mkdir "$n20"
fi
if [ ! -d $msat ]
then
mkdir $msat
if [ $? -ne -0 ]
then
echo "Failed mkdir $msat"
fi
fi
for a in 30 40 50 60 70 80
do
aa=${msat}/a"$a"
mkdir -p $aa
if [ $? -ne -0 ]
then
echo "Failed mkdir $aa"
fi
done
1 Like