home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # Print the size of a file in a "nice" way. Just call it with the name of
- # the file as parameter
- #
-
- /bin/ls -l $1 | \
- gawk ' \
- { \
- size = $5; \
- if (size < 2000) \
- print size " Bytes"; \
- else if (size < 10000) \
- { \
- size = int((size+51)*10/1024)/10; \
- print size " KB"; \
- } \
- else if (size < 100000) \
- { \
- size = int((size+512)/1024); \
- print size " KB"; \
- } \
- else if (size < 10000000) \
- { \
- size = int((size+51200)*10/(1024*1024))/10; \
- print size " MB"; \
- } \
- else \
- { \
- size = int((size+512000)/(1024*1024)); \
- print size " MB"; \
- } \
- }'
-