Help: traversing subdirectories with a coomand-line parameter in csh/tcsh

Help: traversing subdirectories with a coomand-line parameter in csh/tcsh

Post by Jason R Fost » Sun, 07 Apr 1996 04:00:00



I am in need of a way to traverse a series of subdirectories from
the working directory and perform certain operations in those directories.
I have the script to perform the operations but I can not figure out how
to traverse a directory tree.

Here are some examples of callin:

makems -r
 checks names in current directory and all subdirectories

makems /home
 check names in /home directory

makems -r /home
 check names in /home and all subdirectories of /home

I would greatly appreciate any assistance in this matter.

Jason Foster


 
 
 

Help: traversing subdirectories with a coomand-line parameter in csh/tcsh

Post by UnixMyLo » Sun, 07 Apr 1996 04:00:00


How about using the find command:

            find start_directory -exec command {} \;

Example:   find . -exec chown sid {} \;
                 find /home -exec yourshell {} \;

or for specific file names:  

                 find . -name "myfiles*" -exec chown sid {} \;

Anyway, find can be set up to work on just directories or just files, etc.

Hope this helps,

Jane

 
 
 

Help: traversing subdirectories with a coomand-line parameter in csh/tcsh

Post by Gary M. Greenbe » Mon, 08 Apr 1996 05:00:00



[posted && emailed]
Quote:>  I am in need of a way to traverse a series of subdirectories from
>  the working directory and perform certain operations in those directories.
>  I have the script to perform the operations but I can not figure out how
>  to traverse a directory tree.

[snip]
I'm not real clear on what you need but why not just:

    find . -type d -exec "do your thing here" {} \;

Happy Easter,

gary    /* the Sorcerer's Apprentice */
    http:/jax.jaxnet.com/~garyg/main_page.html

Free Speech in America *ed by the Communications Decency Act.
      (((U.S. Congress && Executive) == (Collective Moron)) == 1)