0

Possible Duplicate:
Using `find -perm` to find when a permission is not set

I have a list of directories in which some do not have access permissions. How can I create an array so that it contains only accessible directories using csh.

My code looks like as follow :

set array = (`find $path_to directories -type d -name "*_xyz"`)

it gives me whole list of directories matches to _xyz extension including without access permissions dir as well but I dont want them to be in list.

Community
  • 1
  • 1
XYZ_Linux
  • 3,247
  • 5
  • 31
  • 34
  • You can add `-perm` flags to the `find` command line, it's not clear from your questions what permissions exactly you are looking for but this should hopefully get you started. – tripleee Jan 08 '13 at 18:25
  • I'm resisting the urge to post a link to http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ – tripleee Jan 08 '13 at 18:29
  • actually I need to cd to each directory in the $array. bt when it reach to a non accessible directory program halts . how can I avoid this so that my loop simply go to the next directory. code is foreach dir ($array) cd $dir echo "directory is $dir" cd - end .. please help – XYZ_Linux Jan 08 '13 at 18:40

1 Answers1

2
set array = (`find . -type d -perm /g+x,o+x -name "*_xyz"`)

with that -perm parameters it search only folders accessible by the owner or the group

Davide Berra
  • 6,387
  • 2
  • 29
  • 50