cancel
Showing results for 
Search instead for 
Did you mean: 

Awk

Kyle D. Harris
Regular Advisor

Awk

How do you do a search for files in a directory that are greater then say 10000 ? Any help would be great! Thanks in advance!

Kyle
7 REPLIES
Huc_1
Honored Contributor

Re: Awk

It's not the awk but it works

find / -name "*" -size +10000 -print

just adapt path to your need like
"find /tpm/blabla"

never had to do it any other way' will invetigate how to this in awk, if you still need it

keep us informed of progress.

J-P
Smile I will feel the difference
Balaji N
Honored Contributor

Re: Awk

quesiton is not very clear.

what is greater than 10000? file size

find . -size +10000c

-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Dave Falloon
Trusted Contributor

Re: Awk

another less straight forward way would be something like:

du |sort -nr |more

this will show you the size of ALL files below you current working directory starting with the largest files at the top and the smallest at the bottom. If you want file sizes in Kbytes then add a -k to the du command

ie. du -k | sort -rn | more

But I would use the find command as it is a lot cooler and a better command to master in the long run.

Dave
Clothes make the man, Naked people have little to no effect on society
Patrick Van Humbeeck
Valued Contributor

Re: Awk

since you are mentionning awk, maybe it's the number of lines in an ascii file you're interested in ? check out the wc -l command (man wc).

if it's about file size then your question has been answered already.
Jerome Henry
Honored Contributor

Re: Awk

If you want to save time, have a look at 'locate'.
First do 'updatedb' (it's done 5 mn after system boot each time, so don't do it if you didn't install sth new).
Then locate 'filename', it search in the database made thru updatedb, it's faster than find command...

hth

J
You can lean only on what resists you...
Dave Falloon
Trusted Contributor

Re: Awk

The locate command is faster, but I don't think you can give it specific search criteria, in Kyle's case file size. I think you would have to additionally filter locates output.

For example:

for i in `locate *.h|grep `;do ls -s $i; done |sort -n

something like that.

I hope that helps,

Dave
Clothes make the man, Naked people have little to no effect on society
Jean-Luc Oudart
Honored Contributor

Re: Awk

You can use this script (I regularly use on HPUX)
create the script then run ls -l and pipe into the script (I named it newbgfile)
ll | newbgfile 6
6 is the minum number of digit for the size.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/ksh

if [ $# -eq 1 ]; then
num=$1
else
num=7
fi
awk -v numlen=$num '{
if(length($5) > numlen ) print $0; }'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rgds,
Jean-Luc
fiat lux