Hi All I have two scripts which i used to try and list all the directories one using 'function', which only lists the first directory and does not show directories within directories.
function ListDir ()
{
for arg in $(ls $HOME)
do
if [ -d $1/$arg ]
then
echo $arg
ListDir $arg
fi
done
}
Result
home/<username>/
backup
bin
computer
unix
oracal
There are driectories within 'computer' and 'unix' (prob with loop i think)
The other lists, as i want it, but also includes the complete path name which i dont want. i tried using 'for'
for arg in `find $HOME -type d -exec ls -d {} \;`
do
echo $arg >> outputfile
done
rm outputfile
Result
/home/<username>/
/home/<username>/backups
/home/<username>/bin
/home/<usermane>/computer
/home/<username>/computer/dept
/home/<username/unix
/home/<username>/unix/accounts
/home/<username>/oracal
This goes through a funny loop repeating its self and addidn the new found dir to the end
As you can see i just need the last directory
I know you can do it so come on help me out thank you
Chassis