Advertisement
NLinker

Status of the cp command being executed

Feb 26th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | None | 0 0
  1. # from http://unix.stackexchange.com/a/66800
  2. function cpstat()
  3. {
  4.   local pid="${1:-$(pgrep -xn cp)}" src dst
  5.   [[ "$pid" ]] || return
  6.   while [[ -f "/proc/$pid/fd/3" ]]; do
  7.     read src dst < <(stat -L --printf '%s ' "/proc/$pid/fd/"{3,4})
  8.     (( src )) || break
  9.     printf 'cp %d%%\r' $((dst*100/src))
  10.     sleep 1
  11.   done
  12.   echo
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement