I'm sure there's some incredibly stupid oversight in all of this, but I can't seem to find it.
Code:
#!/bin/bash
base_path="/home/linmix/"
case $1 in
-pm)
test "$base_path/$2" != " " || mkdir "$base_path/$2"
cd $base_path/$2
for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 ; do
touch ${i}.txt
done
exit
;;
(etc)
What's causing me trouble is that I cannot figure out how to get mkdir to work only if there is no dir already in place. The either works if there is no file and gives me a mkdir warning if there is one, or it exits saying it can't cd if there was no previous file and works fine if there is.
The stupidest thing is I had it working, then I made some changes and now I can't get it right again!
I've also tried
Code:
if test "$base_path/$2" = " " ; then
mkdir "$base_path/$2"
fi
But with the same result
command issued: ./script -pm 002
output: mkdir: cannot create directory `/home/linmix/002': File exists
I've also tried
[code]test "$base_path/$2" = " " && mkdir "$base_path/$2"/code]
sane problem...