Operating System - HP-UX
1748117 Members
3742 Online
108758 Solutions
New Discussion юеВ

how to search file from size

 
SOLVED
Go to solution
Jojo Castro
Regular Advisor

how to search file from size

Hi,

In HP-UX, what is the command to find with the exact same size?
For example, im having a file named file1.

$ ll file1
r--r--r--- 1 root bin 70224 Aug 27 2004 file1

I want to find other files with the same size as file1 (which is 70224).

Thanks!
5 REPLIES 5
Dennis Handly
Acclaimed Contributor
Solution

Re: how to search file from size

You can hard code the size:
find path1 -size 70224c

If you want to automate the size part:
find path1 -size $(ll file1 | awk '{print $5}')c
Jojo Castro
Regular Advisor

Re: how to search file from size

Thanks D.H.
James R. Ferguson
Acclaimed Contributor

Re: how to search file from size

Hi Jojo:

I can't help but wonder if you are looking for a way to find hard-linked files: those that have a common inode but differ in their name.

If this is the case, use 'ls -il' to list the inode number of files in the first column of the output. Then do:

# find . -xdev -inum -exec ls -ld {} +

Remember that inodes are only unique within a filesystem. Hence, you should add '-xdev' to the find arguments to make sure that the search doesn't cross filesystems.

Regards!

...JRF...

Mohammad Sanaullah
Frequent Advisor

Re: how to search file from size

to find the file of a particular size on the system

#find / -size c -print

It will look into entire system and print the output files with defined size.

Is this search meant for the duplicate or backup file with changed names on the system?
Alive
Anoop Sivan
Frequent Advisor

Re: how to search file from size

Jojo,

cd /
# du -sk * |sort -rn |more --> This will sort big files in ascending order


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

regards,
Anoop