[ale] bash/korm mkdirs
Oysgelt, Moisey G [GMG]
moisey.g.oysgelt at mail.sprint.com
Thu Sep 11 11:29:43 EDT 2003
so I used cigwin to wrote next script
----------------
#!/usr/bin/bash
# set -x trace
dir=""
function _m_d()
{
if [[ -n $1 ]] ; then
dir="$dir$1"
if test ! -d $dir ; then
mkdir $dir
fi
dir="$dir/"
fi
}
function _mkdirs()
{
dir=""
bigdir=$1
bigdir=`echo $1 | sed 's/ /\\\\ /g'`
sdir=$(echo $bigdir | awk -F "/" '{print $1}')
if [[ -n $sdir ]] ; then
_m_d $sdir
else
return
fi
sdir=$(echo $bigdir | awk -F "/" '{print $2}')
if [[ -n $sdir ]] ; then
_m_d $sdir
else
return
fi
sdir=$(echo $bigdir | awk -F "/" '{print $3}')
if [[ -n $sdir ]] ; then
_m_d $sdir
else
return
fi
sdir=$(echo $bigdir | awk -F "/" '{print $4}')
if [[ -n $sdir ]] ; then
_m_d $sdir
else
return
fi
if [[ -n $sdir ]] ; then
_m_d $sdir
else
return
fi
## and so on up to 20
}
_mkdirs "a/b/c/da/b/c/da/b/c/d"
----------------
***********************
I wanted to make a loop
like
function _mkdirs()
{
dir=""
bigdir=$1
x=1
while [[ $x -le 2 ]]; do
stmp="echo $bigdir | awk -F "/" '{print \$$x}'"
sdir=`$stmp`
if [[ -n "${sdir}" ]]; then
_m_d ${sdir}
else
return
fi
x=$(($x+1))
done
exit;
}
done
****************
but this did not fly
What wrong did I do. Do I miss something fundamental in korn.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 9/1/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 9/1/2003
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ale
mailing list