There are many ways you can go about this. A very quick way is to use the find2perl command to create a script that you can the modify to your heart's content to do exactly what you want it to do.
For instnace I run:
unixprompt> mydir=/www/stage/sites/MyCompany/docs/systems/foo/document +ation unixprompt> find2perl $mydir -depth -type d -print > myscript
Now you will have a script called "myscript" that looks like:
#! /usr/bin/perl -w eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use File::Find (); # Set the variable $File::Find::dont_use_nlink if you're using AFS, # since AFS cheats. # for the convenience of &wanted calls, including -eval statements: use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; sub wanted; # Traverse desired filesystems File::Find::finddepth({wanted => \&wanted}, '/www/stage/sites/MyCompan +y/docs/systems/foo/documentation'); exit; sub wanted { my ($dev,$ino,$mode,$nlink,$uid,$gid); (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && -d _ && print("$name\n"); }
Now you can take and modify where it says "print" under the sub "wanted" and make it do whatever you want.
You could also handroll all this instead of cheating and using find2perl....
| Peter L. Berghold -- Unix Professional Peter at Berghold dot Net | |
| Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice. | |
In reply to Re: Checking subdirectories in a given path
by blue_cowdawg
in thread Checking subdirectories in a given path
by aarestad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |