du -k -a | sort -n -r | head -$1 | awk -e
'{printf"%-30s%10.3f\n",$2,$1/1000}'
The above script gives me the names of the sub-directories and files.
Is there a way to eliminate the directory entries?
Is there a simpler way to do this job?
--
Venugopal
--
Posted via CNET Help.com
http://www.help.com/
Here's a crude shell script I wrote at least 15 years ago (it still uses
awk, and everything I've written since 1990 or so is perl :-). I call this
``lsize'', and it totals the size of all files in a directory. The -r
option sorts by size in reverse order.
Bill
--
INTERNET: bi...@Celestial.COM Bill Campbell; Celestial Software LLC
UUCP: camco!bill PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/
``Never blame a legislative body for not doing something. When they do
nothing, that don't hurt anybody. When they do something is when they
become dangerous.''
Will Rogers
Sorry piggyback your post, Bill, but I lost the
original, and I just thought I'd throw this out there:
9.3 How do I find the largest files?
18 Sept 1999
----------------------------------------
To find the largest files, in units of bytes, one can use 'find,'
'ls,' 'awk,' 'sort,' and 'less':
find / -type f -exec ls -l {} + | awk '{ print $5 "\t" $9 }' \
| sort -nr | less
To find the largest files, in units of kilobytes:
find / -type f -exec ls -l {} + | awk '{ print int($5/1024) "\t" $9 }' \
| sort -nr | less
Matt
You can filter the output of du -a through:
while read size file; do [ ! -d "$file" ] && echo "$size $file"; done
+Is there a simpler way to do this job?
It isn't simpler, but I use: ftp://ftp.armory.com./pub/scripts/bigfiles
John
--
John DuBois jo...@sco.com KC6QKZ/AE
I wish to God these calculations had been executed by steam. - Charles Babbage
What a *horrid* slow script!
Do NOT use find's -exec option, that's going to spawn one 'ls' for every
file on the machine! Use xargs!! And forget the awk script and its
arithmetic too: don't use ls -l, but ls -s. Filter out chaff using
find's -size option too.
--
JP
No one recommended that you use a script you find disagreable.
It takes all of 40 seconds, which is just fine with me, and it
works. Thanks for the negativity, though, you prick.
Matt
Matt,
Every blue moon or so, someone whom has not had the pleasure
of spending any quality time with JP Radley, calls him a prick
(among other things). He can be very frank at times, and as in your
case possibly abrasive. Let me assure you though that it is not a
personal attack on you. If you spent any time with JP you would know
what I mean. I speak from the heart here, as I've known JP for
too many years, and have spent enough time with him, to try and make
this an opportunity to gain any brownie points. Your reply does
however serve as a reminder to JP that he needs to revisit some
of his wording from time to time. He's an OK guy.
Best Regards,
Jeff Hyman
.--.
__________________________ .-. | | __________________________________
Lone Star Software Corp. | | | | .-. Email: je...@cactus.com
Cactus International, Inc. | |_| | | | Sales: (800) 525-8649
509 E. Ridgeville Blvd. _ |___ |_| | Support: (301) 829-1622
Mt. Airy, MD 21771 _| ~- | ___| Fax: (301) 829-1623
http://www.CACTUS.com \, _} | |
------------------------- \( -- | | -----------------------------------
| |
> Every blue moon or so, someone whom has not had the pleasure
> of spending any quality time with JP Radley, calls him a prick
> (among other things). He can be very frank at times, and as in your
> case possibly abrasive. Let me assure you though that it is not a
> personal attack on you. If you spent any time with JP you would know
> what I mean. I speak from the heart here, as I've known JP for
> too many years, and have spent enough time with him, to try and make
> this an opportunity to gain any brownie points. Your reply does
> however serve as a reminder to JP that he needs to revisit some
> of his wording from time to time. He's an OK guy.
Bright people often seem abrasive (I am hardly EVER seen as being
guilty of that sin; the last person to gaze in awe at my
brilliance was around 4 years old, I think- and even she wasn't
all that impressed).
People who are very, very busy and are doing the work of ten
ordinary folks also may seem curt and unfriendly, especially when
the "work" is unpaid (I'm definitely not in that class either.
When it comes to hours worked per week, my attitude is "fifty is
nifty but twenty is plenty").
The aforementioned person who supposedly resembles a penis or a
sharp thorn is both bright and very, very active. Especially
here.
Some of us are very good at this stuff. Some of us just muddle
by. I have more sympathy with the muddlers, so I don't dare say
anything about someone's scripting unless it is COMPLETELY
broken. Nonetheless, while JPR's comments may have burned
slightly, they were accurate.
JP *is* an OK guy. I'm sure Matt is too. Perhaps JP could gain
more admiration by choosing words more carefully, but I doubt the
percentage gain would be worth the effort.. most folks care more
about the quality of the advice than the pretty package it's
wrapped in.
--
Tony Lawrence (to...@aplawrence.com)
SCO/Linux articles, help, book reviews, tests,
job listings and more : http://www.pcunix.com
In my part of the country they call this a "pedophile". <VBG>
> People who are very, very busy and are doing the work of ten
> ordinary folks also may seem curt and unfriendly, especially when
> the "work" is unpaid (I'm definitely not in that class either.
> When it comes to hours worked per week, my attitude is "fifty is
> nifty but twenty is plenty").
I'd put money on the fact that getting-paid had no influence
on JP's reply. He's a very wealthy man in more ways then one,
and is not easily influenced by OPM. This is not to say that
he may not generate income from his presence here... but it's
not his motive.
>
> The aforementioned person who supposedly resembles a penis or a
> sharp thorn is both bright and very, very active. Especially
> here.
>
> Some of us are very good at this stuff. Some of us just muddle
> by. I have more sympathy with the muddlers, so I don't dare say
> anything about someone's scripting unless it is COMPLETELY
> broken. Nonetheless, while JPR's comments may have burned
> slightly, they were accurate.
>
> JP *is* an OK guy. I'm sure Matt is too. Perhaps JP could gain
> more admiration by choosing words more carefully, but I doubt the
> percentage gain would be worth the effort.. most folks care more
> about the quality of the advice than the pretty package it's
> wrapped in.
It is always worth while to consider how others may think
of you before you post. No harm will come to anyone if they
at least attempt to consider the other persons feelings.
Concerning Matt... I'd probably like him, as he had the *alls
to say what was on his mind in a public reply. I'm taking no
sides here. I just want to throw in a few words to help keep
the peace. BTW: You're OK in my book too. :-)
Enjoy the weekend,