Operating System - HP-UX
1751832 Members
5185 Online
108782 Solutions
New Discussion юеВ

Re: searching files datewise and sizewise in a particular file system

 
SOLVED
Go to solution
Shivkumar
Super Advisor

searching files datewise and sizewise in a particular file system

Dear Sirs,

I am using the below commands to find the files generated after 15th jan 2006.

$ touch -amt 01150001 /tmp/jasmine
$ find /opt/bea -type f -newer /tmp/jasmine -exec ls -l {} \;

Now suppose i want to know the files having size more than 25MB or 1.5 GB then how do i include in the above command ?

Thanks,
Shiv
8 REPLIES 8
Pete Randall
Outstanding Contributor

Re: searching files datewise and sizewise in a particular file system

Something like this:

find /opt/bea -type f -newer /tmp/jasmine -size +25000c -exec ls -l {} \;


Pete

Pete
Patrick Wallek
Honored Contributor
Solution

Re: searching files datewise and sizewise in a particular file system

Close Pete, but you are a factor of 1024 off. The size in find, when using '-size +1234c', is in bytes.

So 25MB would be:

find /opt/bea -type f -newer /tmp/jasmine -size +25000000c -exec ls -l {} \;

For 1.5GB:

find /opt/bea -type f -newer /tmp/jasmine -size +1500000000c -exec ls -l {} \;
Pete Randall
Outstanding Contributor

Re: searching files datewise and sizewise in a particular file system

Thanks, Patrick. I looked at that three times before I submitted and I still couldn't decide if I was right or not.


Pete

Pete
Raj D.
Honored Contributor

Re: searching files datewise and sizewise in a particular file system

Shiv ,

for size use "-size +25000000c " parameter with find command , i.e 25MB.


+25000000c = 25+6(zero) Byte = 25 Mega Byte.


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
James R. Ferguson
Acclaimed Contributor

Re: searching files datewise and sizewise in a particular file system

Hi Shiv:

If you want to count in blocks (1-block = 512 characters) drop the "c" from the size specification.

See the manpages for 'find'. The specification of a numeric argument to options like '-size' can be positive (more than); negative (less than) or equal (unsigned).

You can also add boolean logic with '-a' and/or '-o'. Parentheses need to be escaped. Thus we could write:

# find /opt/bea -type f -newer /tmp/jasmine -a \( -size +25000000c -a -size -15000000000c \) -exec ls -l {} \;

Regards!

...JRF...
Arunvijai_4
Honored Contributor

Re: searching files datewise and sizewise in a particular file system

Hi Shiv,

Specifying -size with find will be helpful to you.

# find /opt/bea -type f -newer /tmp/jasmine -size 25000 -exec ls -l {} \;

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Yogeeraj_1
Honored Contributor

Re: searching files datewise and sizewise in a particular file system

hi shiv,

you may also wish to redirect the output to a file for easy review after the execution of the command.

... -exec ls -l {} >> /tmp/mylog.log \;

helpful in cases where you have many files

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Senthil Prabu.S_1
Trusted Contributor

Re: searching files datewise and sizewise in a particular file system

Hi shiva,
use the switch "size" along with the find command.

ex:
$DIR=/opt/bea
find $DIR -type f -newer /tmp/jasmine -size 25000 | xargs ls -lrt
One man's "magic" is another man's engineering. "Supernatural" is a null word.