Operating System - HP-UX
1753481 Members
4985 Online
108794 Solutions
New Discussion юеВ

Re: How to traverse sub. dirs?

 
SOLVED
Go to solution
Wodisch_1
Honored Contributor

Re: How to traverse sub. dirs?

Hi,

well, how about using the feature of "find" to tell multiple starting directories?
Since that would be less than 49 if I read your posting correctly, you would go by with a single "find" command:

cd /u5/data
find tom* -exec net perms {} ";"

You could use any list or wildcard pattern you want!
If you don't like the subdirs starting with "m", that would be

find [^m]* -exec net perms {} ";"

HTH,
Wodisch
Darrell Allen
Honored Contributor
Solution

Re: How to traverse sub. dirs?

For output to 49 different files, perhaps:

for dir in *
do
find $dir -exec net perms {} \; >/some_dir_path/output.$dir
done

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Michael Steele_2
Honored Contributor

Re: How to traverse sub. dirs?

Yes Darrell that is what I've been looking for but net perms has thrown in an additional twist. Here is the net perms syntax:
"net perms c:/u5/data" so your answer fails when c: is added like so "find /u5/data -exec net perms c: {} \;" So I'm back to embedded loops unless you also know of a way to catenate the string "c:" in front of a find result?
Support Fatherhood - Stop Family Law
Bill Hassell
Honored Contributor

Re: How to traverse sub. dirs?

If you give find a starting directory, then it will traverse through that directory. However, you did not give find a single directory. Instead, you combined the shell's built-in filename globbing with find (ie, the *). The * is not seen by the find command at all. Instead, find saw a long list of names in the directory. To see what find is seeing, surround the entire line in "" and put echo in front:

echo "find u5/data/tomx/*"

The find command is getting help from the shell which is not what you intended. Using * in find almost always causes uinexpected problems and find does not need * because the default is to identify everything in the current directory and compare that to whatever options you've added (like -type f or similar).
As a rule, never use * in a find command unless you know what the effect is (hint: use the echo above)



Bill Hassell, sysadmin
Darrell Allen
Honored Contributor

Re: How to traverse sub. dirs?

I'm afraid I'm stumped by that too. I believe I'd also capture the output to a file and go from there. Like you say, use an embedded loop.

Any way, welcome to the ITRC forums. They've been very helpful to me. Hope you find them useful also. They become addictive after awhile.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Jack Werner
Frequent Advisor

Re: How to traverse sub. dirs?

This solution might be termed un-elegant or quick&dirty;
Why not redirect the std out of a find /u/data -exec ls -l {} ]; > find.out for example.
Then use vi to make any changes you want. Granted, this is quick and dirty and you need enough memory to vi a 100M file. Set x permission on the file and execute it after you have finished making your changes. BTW does net_perm expect a file or a directory and couldn't you look at the net_perm source and simplify this entire process a lot?
i'm retired