If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):
From: Bill Campbell <bill@celestial.com> Subject: Re: sco-list: Locating large files Date: Wed, 10 Jan 2001 16:52:42 GMT References: <t5o3s4sgrqsqb6@corp.supernews.com> --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii
On Wed, Jan 10, 2001 at 07:30:12AM -0000, Venugopal wrote:
>Frequently I need to create space on my server.I have written the
>following script to locate the biggest files in a given directory.
># shell script fbf to get given no. of big files
># usage fbf nn where nn is the requd. no. of files
>
>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?
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: bill@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
--TB36FDmn/VVEgNH/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=lsize
case $# in
0) args="*" ;;
*) case $1 in
-r) SORT=TRUE;
shift;
;;
esac
args="$*";
;;
esac
case $SORT in
TRUE) ls -li $* | sort +0n -u |
sort +5rn |awk '{sum+=$6; printf("%8d %8d %s\n",sum, $6, $10)}'
;;
*)
ls -l $* | awk '{sum+=$5; printf("%8d %8d %s\n",sum, $5, $9)}'
;;
esac
--TB36FDmn/VVEgNH/--
/Bofcusm/954.html copyright 1997-2004 (various authors) All Rights Reserved
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar