Hi
I need to make a script that can go throu a file system an in every dir execute a command.
the script should have 3 parameters $1 the number of levels I need to gå throu $2 directory where it should start and $3 the command to execute(could be put into the script).
ex.
dirthrou.sh 2 /opt "ls > /ls_on2_levels_in_opt.txt"
the out put should be an ls in /opt, /opt/bin and /opt/var ect. but not in /opt/var/test
I made a script that takes 1 level under - but this needs to be more recusive, and go throu X levels
set -A dirs `ls -lrt |grep "^d"|awk '{print $9}'
length=${#dirs[*]}
#echo $length
loop=0
while [ $loop -lt $length ]
do
echo ${dirs[$loop]}
cd ${dirs[$loop]}
ls > test
cd ..
(( loop=$loop+1 ))
done
Hope some one can help.
I need to make a script that can go throu a file system an in every dir execute a command.
the script should have 3 parameters $1 the number of levels I need to gå throu $2 directory where it should start and $3 the command to execute(could be put into the script).
ex.
dirthrou.sh 2 /opt "ls > /ls_on2_levels_in_opt.txt"
the out put should be an ls in /opt, /opt/bin and /opt/var ect. but not in /opt/var/test
I made a script that takes 1 level under - but this needs to be more recusive, and go throu X levels
set -A dirs `ls -lrt |grep "^d"|awk '{print $9}'
length=${#dirs[*]}
#echo $length
loop=0
while [ $loop -lt $length ]
do
echo ${dirs[$loop]}
cd ${dirs[$loop]}
ls > test
cd ..
(( loop=$loop+1 ))
done
Hope some one can help.