The solution to this dilemma is the Unix utility
du. This little utility will
recurse through all subdirectories and display all the blocks being used. In the display below,
the directory being processed contains a perl
subdirectory, which in turn contains a src subdirectory. The src directory
contains files totaling 1540 blocks. The perl directory count includes all the
blocks in src plus the blocks used by files in perl. Finally, the top level
includes all blocks below it, plus blocks used by files used in the current
$ du 1540 ./perl/src 5648 ./perl 5654 .
-a option displays the details for each file.
$ du -a 1500 ./perl/src/big.prl 40 ./perl/src/prog.prl 1540 ./perl/src 4108 ./perl/perl.tar 5648 ./perl 2 ./minutes.txt 4 ./note.txt 5654 .
du command will cut through a lot of
It provides size information as well as a reasonable display of the directory tree.
Switching things around with tr
tr utility translates one set of characters into another.
tr abc def test.txt will process the records from test.txt and will translate the letter a to d, the letter b to e and the letter c to f. At first glance this doesn't seem very useful, unless you want to
practice amateur cryptography, but
tr has additional options that make it much
more powerful. Two examples should give you a feel for the command.
The characters to be translated can be expressed as a range. In the
command below, a directory is output through
translates a to A, b to B and so on -- converting everything from lowercase to uppercase.
$ ls -ls|tr [a-z] [A-Z] TOTAL 6 2 -RW-R--R-- 1 MJB GROUP 3 FEB 04 23:31 MINUTES.TXT 4 -RW-R--R-- 1 MJB GROUP 1201 FEB 04 23:25 NOTE.TXT 2 DRWXR-XRX 2 MJB GROUP 128 JAN 29 18:53 PERL
Using tr in the real world