Results 1 to 2 of 2
I have an array setup:
nodirs=("virtfs" "lost+found" "domlogs")
for x in `ls /home`
do
if [-d $x ]
then
echo $x
fi
done
That will print and output of all ...
- 03-17-2009 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 2
BASH: traverse *some* directories
I have an array setup:
nodirs=("virtfs" "lost+found" "domlogs")
for x in `ls /home`
do
if [-d $x ]
then
echo $x
fi
done
That will print and output of all dirs under home, I want to avoid anything in the 'nodirs' array. I plan on going into each of those dirs and doing trivial task like 'du' and other things.
BASH array is very difficult for conditional. If anyone could help with conditional so it no traverse into any value in 'nodirs' array I would be greatful much so.
- 03-30-2009 #2Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
you could pass the result through egrep with -v to negate the match:
Code:ls /home | egrep -v "virtfs|lost\+found|domlogs"
RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.


Reply With Quote