Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Display progress reading/writing a file according to position information on the file descriptor.
# Usage: $(pgrep myprocess) $FD_NUMBER
# Find $FD_NUMBER by doing: ls -l /proc/$(pgrep myprocess)/fd/
name=$(readlink $fd)
size=$(wc -c $fd | awk '{print $1}')
while [ -e $fd ]; do
progress=$(cat $fdinfo | grep ^pos | awk '{print $2}')
echo $((100*$progress / $size))
sleep 1
done | dialog --gauge "Progress reading $name" 7 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment