Operating System - HP-UX
1844043 Members
2227 Online
110227 Solutions
New Discussion

find command giving unexpected output

 
SOLVED
Go to solution
Sunny Jaisinghani
Trusted Contributor

find command giving unexpected output

Hello All,

I am runnig the following command

find / -xdev -size +100000c -exec ls -lt {} \; | more

The output of this command gives me files and directories of /, /tmp & /home

The files from /tmp and /home are not expected in this output.

Am i missing something over here. ???
12 REPLIES 12
Robert-Jan Goossens_1
Honored Contributor

Re: find command giving unexpected output

Hi Sunny,

Just to be sure :-) /tmp and /home are not part of / root filesystem?

Could you post your HPUX version.

Regards,
Robert-Jan
spex
Honored Contributor

Re: find command giving unexpected output

Hello,

It seems as though /tmp and /home are subdirectories of /.

Run this command:
$ bdf / /tmp /home
and see if the filesystem is the same for each.

PCS
Sunny Jaisinghani
Trusted Contributor

Re: find command giving unexpected output

I very well know that /tmp and /home are not a part of / FS.

# bdf / /tmp
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 212992 197577 14464 93% /
/dev/vg00/lvol5 1048576 39086 949004 4% /tmp


/ , /tmp & /home are all different file systems...

Still the find command shows files from those directories.

# uname -a
HP-UX XXXXXXXX B.11.11 U 9000/800 1772297399 unlimited-user license
Robert-Jan Goossens_1
Honored Contributor

Re: find command giving unexpected output

john korterman
Honored Contributor

Re: find command giving unexpected output

Hi Sunny,

you should specify plain files only, e.g.:
# find / -type f -xdev -size +100000c -exec ls -lt {} \; | more

if you do not, your find command will also include directories and the ones mentioned are probably the ones on your system which are above the size specified and thus included for ls.

regards,
John K.
it would be nice if you always got a second chance
Sunny Jaisinghani
Trusted Contributor

Re: find command giving unexpected output

Hello John,

I got your point. However if i am including the filter -xdev it should ideally not consider /tmp and /home directories as they are under different mount point.

Am i right???
Sunny Jaisinghani
Trusted Contributor

Re: find command giving unexpected output

Also when i use -type f filter i get a perfect output.

Thanks John
john korterman
Honored Contributor
Solution

Re: find command giving unexpected output

Hi again Sunny,

all mount points are in the root or / filesystem, i.e. they are there as (directory)files of a certain size.
Apparently /home and /tmp have a size that meets your reuirement and are therefore they "victims" of the ls command.
Thus your find command does not cross mount points, but you did not get what you wanted.

Try changing the size and you may see the effect of ls on other mount points.

regards,
John K.
it would be nice if you always got a second chance
Sunny Jaisinghani
Trusted Contributor

Re: find command giving unexpected output

Hi John...

I observed the change in output. U r right.

So will the patch mentioned by Robert in previous post take care of this..

i mean do not victimise the other directories
or the only solution to this is to make sure i use -type filter.

Sunny
James R. Ferguson
Acclaimed Contributor

Re: find command giving unexpected output

Hi Sunny:

John's use of '-xdev' is correct and the 'find' patch mentioned isn't going to change the behavior you observer whether or not it is installed.

The manpages for 'find' clearly note tat '-dev' ...causes find to avoid crossing any file system mount points that exist below starting points enumerated in pathname_list."

Thus if you want to confine your search to the '/' mountpoint (and thus directories like '/etc/ and '/sbin' which are not mountpoints), use 'find / -xdev ...'.

Regards!

...JRF...
Sunny Jaisinghani
Trusted Contributor

Re: find command giving unexpected output

The solution to the above issue is to use appropriate filter with the find command. In this case using -type f filter solved my doubts.

Thanks to all
john korterman
Honored Contributor

Re: find command giving unexpected output

Hi Sunny,

your original command does not cross any mountpoints - this is important to notice.

But your original command does not distinguish between different types of files; and directories are also files, among other things they have a certain size.

Your original command includes files of any type in the root directory that are bigger than the specified size.
It is just a coincidence that the two directories /tmp and /home are also mountpoints, and your find command makes thus "ls -lt /tmp" and "ls -lt /home".
You could actually have directories in the root file system bigger than the specified size, and your find would also "ls -lt" them.
You should notice that you get the output of "ls -lt /tmp" and "ls -lt /home" but the files listed by that operation are not necessaricily as big as the size specified.



regards,
John K.
it would be nice if you always got a second chance