On 10/22/07, Stephen Ryan <[EMAIL PROTECTED]> wrote: > On Mon, 2007-10-22 at 09:11 -0400, Kent Johnson wrote: > > Newbie question: > > > > How can I get the total size, in K, of all files in a directory that > > match a pattern? > > > > For example, I have a dir with ~5000 files, I would like to know the > > total size of the ~1000 files matching *.txt. > > > > du -c *.txt | tail -1
Since I know Kent has a Mac and this might be on his laptop, I'd like to add that this should really be: du -ck *.txt | tail -1 Although Linux (ie GNU) du defaults to outputting sizes in k, OS X does not. It counts blocks (512 byte blocks) and the -k option to du explicitly says "I want output in k" and GNU du honors this even though it's the default). For additional examples... Solaris 9 == 512 by default, FreeBSD 6 == 1024 by default, NetBSD 1.6.1 == 512 by default, but they all honor -k -Shawn > > (That's "-(one)", not "-(ell)", meaning, you only want the last line of > output from du.) > > du prints out the sizes of each of the matching files; '-c' means you > want a total, too; piping the output through tail -1 picks out just the > last line with the total. > > -- > Stephen Ryan > Dartware, LLC > > _______________________________________________ > gnhlug-discuss mailing list > gnhlug-discuss@mail.gnhlug.org > http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/ > _______________________________________________ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/