home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 18
/
aminetcdnumber181997.iso
/
Aminet
/
misc
/
emu
/
AROSdev.lha
/
AROS
/
docs
/
src
/
getfilesize
< prev
next >
Wrap
Text File
|
1997-01-24
|
829b
|
34 lines
#!/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"; \
} \
}'