Operating System - Linux
1753494 Members
5144 Online
108794 Solutions
New Discussion юеВ

Re: Linux equivalent of -local option in find statement

 
Raynald Boucher
Super Advisor

Linux equivalent of -local option in find statement

Hello all,
The "find . -local ..." statement restricted the search to the local machine under HP-UX Unix.

I have a script I want to migrate to a Fedora Core 5 box that uses this option and can't get it to work.
The Linux box has 3 nfs and one samba share filestems on it.

I tried using "find . ! -fstype nfs -a ! fstyep smb -name xxxxx" but the samba share is still searched. How can I search only the local machine without searching each local file system in turn?

[root@stealthdell root]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda1 521748 90040 405204 19% /
/dev/hda5 1027768 750492 225068 77% /usr
/dev/hda7 2079284 1299768 779516 63% /home
/dev/hda8 1019864 150792 817264 16% /var
none 31120 0 31120 0% /dev/shm
romulus:/apps/batch 2097152 1640800 428128 80% /mnt/batch
romulus:/home 4198400 3278240 867392 80% /mnt/g40home
romulus:/nbcase 14581760 6591808 7742176 46% /mnt/nbcase
//persephone/vol1 240361472 83644416 156717056 35% /home/prodsupp/apollo

Thanks
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: Linux equivalent of -local option in find statement

Shalom,

NFS and Samba are somewhat integrated.

You are using the right statement, but may need to update your syestem with bug fixes.

Try find -fstype ext3

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Heironimus
Honored Contributor

Re: Linux equivalent of -local option in find statement

Try "smbfs" instead of "smb" as your fstype.
Raynald Boucher
Super Advisor

Re: Linux equivalent of -local option in find statement

2 good suggestions.
unfortunately neither works.

I tried "-fstype ext3" first and it still grabs floppy, cdrom and nfs as per the following.

I then tried the "not nfs and not smbfs" with identical results. I also tried using parenthesese to group the fstype options but that faile syntax.

Any other suggestions?

[root@stealthdell bin]# find / -fstype ext3 -name '*8.txt'
/usr/share/doc/vim-common-6.0/doc/usr_08.txt
/usr/share/doc/vim-common-6.0/doc/usr_28.txt
/usr/lib/kbd/unidata/UnicodeData-2.1.8.txt
/usr/lib/kbd/unidata/PropList-2.1.8.txt
/usr/lib/kbd/unidata/ReadMe-2.1.8.txt
find: /mnt/floppy: Input/output error
find: /mnt/cdrom: Input/output error
find: /mnt/g40home/nbbuild/.ssh: Permission denied
find: /mnt/g40home/nbbuild/bin: Permission denied
find: /mnt/g40home/nbbuild/Mail: Permission denied
... and so on
Heironimus
Honored Contributor

Re: Linux equivalent of -local option in find statement

Thinking about it, find will probably still crawl the mount points, it's just that none of the files will match. Something like this will probably work, but it seems a little ugly....

find $(mount -t ext3 | cut -f3 -d' ') -xdev ...
Stuart Browne
Honored Contributor

Re: Linux equivalent of -local option in find statement

Or you could marry something with '-mount'.

Also, newer Linux boxen don't use 'smbfs' any more, they use 'cifs'. That being said, showing us the output of a 'mount' command would help in that regard.
One long-haired git at your service...
Raynald Boucher
Super Advisor

Re: Linux equivalent of -local option in find statement

Here is the output from mount:
[boucherr@stealthdell boucherr]$ mount -l
/dev/hda1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev type devfs (rw)
/dev/hda5 on /usr type ext3 (rw)
/dev/hda7 on /home type ext3 (rw)
/dev/hda8 on /var type ext3 (rw)
none on /dev/pts type devpts (rw,mode=0620)
none on /dev/shm type tmpfs (rw)
/mnt/cdrom on /mnt/cdrom type supermount (ro,dev=/dev/hdd,fs=iso9660,--,iocharse
t=iso8859-1)
/mnt/floppy on /mnt/floppy type supermount (rw,sync,dev=/dev/fd0,fs=vfat,--,ioch
arset=iso8859-1,umask=0,codepage=850)
none on /proc/bus/usb type usbdevfs (rw,devmode=0664,devgid=43)
romulus:/apps/batch on /mnt/batch type nfs (ro,soft,addr=xxx.xxx.xxx.183)
romulus:/home on /mnt/g40home type nfs (ro,soft,addr=xxx.xxx.xxx.183)
romulus:/nbcase on /mnt/nbcase type nfs (rw,soft,addr=xxx.xxx.xxx.183)
//persephone/vol1 on /home/prodsupp/apollo type smbfs (0)
[boucherr@stealthdell boucherr]$

I tried "find `grep ext3 /etc/fstab | awk '{print $2}'` -mount" and it looks like it's working.

Just another question:
How do I prevent find from following links?



Stuart Browne
Honored Contributor

Re: Linux equivalent of -local option in find statement

It doesn't by default. You have to put '-follow' to make it show the linked files instead of the symbolic link.
One long-haired git at your service...