Here's a quick hack. If you don't have awk or stat available, I don't imagine you will have
Perl, either.
Code:
#!/bin/sh
#
# cpbar -- era 2008-05-21 for unix.com
#
# Depends:
# stat
# cp
# awk
syntax () {
echo "Syntax: $0 srcfile destfile" >&2
echo " " "$@" >&2
exit 1
}
test -r "$1" || syntax "File '$1' not found"
test -d "$2" && syntax "Must name destination file ('$2' is a directory)"
size=`stat -c %s "$1"`
cp "$1" "$2" &
cppid=$!
trap 'echo; kill $cppid; rm -f "$2"; exit 127' 1 2 3 5 15
while true; do
nsize=`stat -c %s "$2"`
awk -v f1="$1" -v f2="$2" -v size=$size -v nsize=$nsize '
BEGIN { printf "Copying %s to %s: %4.2f%%\r", f1, f2, 100*nsize/size }'
case $nsize in $size) break ;; esac
sleep 1
done
echo
wait $cppid