- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Exclude some dirs from find.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 07:58 AM
тАО08-12-2009 07:58 AM
Exclude some dirs from find.
DIRS=`/sysadmin/ssh_admin/bdfmegs|awk '{print $6}'|grep -v Mounted`
SERVERLIST=/sysadmin/ssh_admin/ssh_script/serverlist_test.txt
OUTPUT=/sysadmin/ssh_admin/output/$(hostname).txt
for i in `cat $SERVERLIST`
do
remsh $i /usr/bin/find $DIRS -xdev \( -name "*.sh" -o -name "*.ksh" \) -exec egrep -q 'remsh|rcp' '{}' \; -print >>$OUTPUT
done
exit
I m struck in some areas, where I need to exclude the .snapshots ( netapp volms) directories from the findтАж. , Awaiting tips from u allтАж.
Thanks,
Ranoop
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 08:44 AM
тАО08-12-2009 08:44 AM
Re: Exclude some dirs from find.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 08:52 AM
тАО08-12-2009 08:52 AM
Re: Exclude some dirs from find.
Something like this would enable you to skip the visit of directories:
# find /somepath -type f -a ! -path "/somepath/dir1/*" -a ! -path "/somepath/dir2/*" -name "*.sh" -exec ls -l {} +
Note that your execution will be much more efficient if you use the "+" terminator instead of the ";" terminator for your '-exec'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2009 11:12 AM
тАО08-12-2009 11:12 AM
Re: Exclude some dirs from find.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2009 01:18 AM
тАО08-13-2009 01:18 AM
Re: Exclude some dirs from find.
Something like this has done the job, -:)
/usr/bin/find $DIRS -xdev \( -name "*.*sh" -a ! -path "*/.snapshot/*" \) -exec egrep -q 'remsh|rcp' '{}' \; -print >>$OUTPUT
But the time taken for the execution is too long, it brings box perfomance down as well..
Any modifications on this would be highly appreciated..
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2009 01:41 AM - edited тАО08-28-2011 09:01 PM
тАО08-13-2009 01:41 AM - edited тАО08-28-2011 09:01 PM
Re: Exclude some dirs from find (-prune)
>where I need to exclude the .snapshots (netapp volumes)
Ding ding! Been there, done that.
The only reasonable solution is using find -prune. (Unless there is some easier gnu find option?)
for i in $(< $SERVERLIST); do
remsh $i -n "find $DIRS -xdev -name .snapshot -prune -o \( -name '*.sh' -o -name '*.ksh' \) \
-exec grep -l -e remsh -e rcp {} + " >> $OUTPUT
done
This removes the egrep hammer and uses multiple grep -e. This removes the -print and uses grep -l. This is needed if using JRF's "-exec ... +".
>Bob: What is unique about the netapp directories that will allow you to ignore them?
These are backups. You don't want to search them. For each directory level, you then have N more subdirectories and it takes "days" to search. That's why -prune.
>JRF: Something like this would enable you to skip the visit of directories:
No, this visits them but doesn't print them. Useless if you want to finish in a timely manner.
>Note that your execution will be much more efficient
Without -prune, this doesn't matter but it is a good practice.
>Alex: And would the netapps volumes be mounted on more than one server
Possibly, so you wouldn't want to search it for each of the SERVERLIST.