find/xargs question...

Robert Nichols rnicholsNOSPAM at comcast.net
Fri Dec 29 05:06:12 UTC 2006


bruce wrote:
> hi...
> 
> i have what i think is a combination find/xargs question....
> 
> i'm trying to search through a dir tree for files matching certain patterns
> and i want to rename the files. i'd also like to ignore certain dirs.
> 
> ie...
> 
> [root at lserver2 wctest]# ls -al
> total 24
> drwxr-xr-x  5 root root 4096 Dec 27 21:46 .
> drwxr-xr-x 48 root root 4096 Dec 27 21:45 ..
> drwxr-xr-x  3 root root 4096 Dec 27 21:46 class
> drwxr-xr-x  3 root root 4096 Dec 27 21:46 faculty
> drwxr-xr-x  7 root root 4096 Dec 27 21:46 .svn
> 
> ./class:
> total 20
> drwxr-xr-x 3 root root 4096 Dec 27 21:46 .
> drwxr-xr-x 5 root root 4096 Dec 27 21:46 ..
> -rw-r--r-- 1 root root  248 Dec 27 21:46 childClass.py
> drwxr-xr-x 7 root root 4096 Dec 27 21:46 .svn
> -rw-r--r-- 1 root root  239 Dec 27 21:46 zu_fl_2772Class.py  <<<<<
> 
> i'd like to find any file with "zu_fl*Class" and replace it with
> zu..ClassFFFF. so basically, i'm finding any given file with a pattern
> followed by Class, and adding FFFF to it along with the file extension.
> 
> i'd also like to ignore specific dirs as well... in this case, i'd like to
> ignore the ".svn" folder...
> 
> this should be pretty esay, but i can't seem to get the nuances down.
> 
> any thoughts/preferrably pointers as to how to perform this action..
> 
> thanks

find /dir -name .svn -prune -o -name 'zu_fl*Class'

Or, adding implied operator and parentheses for clarity:

find /dir \( -name .svn -prune \) -o \( -name 'zu_fl*Class' -print \)

-- 
Bob Nichols         Yes, "NOSPAM" is really part of my email address.




More information about the fedora-list mailing list