|
|
@@ -0,0 +1,38 @@ |
|
|
|
#!/bin/sh - |
|
|
|
|
|
|
|
if [ x"$#" = x"2" -a x"$1" = x"-c" ]; then |
|
|
|
continueous=1 |
|
|
|
shift |
|
|
|
fi |
|
|
|
|
|
|
|
if [ x"$#" != x"1" ]; then |
|
|
|
echo "Usage: $0 <file>" |
|
|
|
exit 2 |
|
|
|
fi |
|
|
|
|
|
|
|
if ! [ -f "$1" ]; then |
|
|
|
echo "$1" does not exist! |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if [ $continueous = 1 ]; then |
|
|
|
lastls=$(ls -l "$1") |
|
|
|
while sleep 1; do |
|
|
|
nextls=$(ls -l "$1") |
|
|
|
( echo "$lastls"; echo "$nextls") | |
|
|
|
grep -v '^total' | |
|
|
|
awk '{ ar[NR] = $5 } |
|
|
|
END { bytes = ar[2] - ar[1]; |
|
|
|
bytespersec = bytes; |
|
|
|
print bytespersec / 1024 / 1024 }' |
|
|
|
|
|
|
|
lastls="$nextls" |
|
|
|
done |
|
|
|
else |
|
|
|
( ls -l "$1"; sleep 5; ls -l "$1") | |
|
|
|
grep -v '^total' | |
|
|
|
awk '{ ar[NR] = $5 } |
|
|
|
END { bytes = ar[2] - ar[1]; |
|
|
|
bytespersec = bytes / 5; |
|
|
|
print bytespersec / 1024 / 1024 }' |
|
|
|
fi |