Advertisement
devinteske

ddrescue-progress.sh

Sep 25th, 2020
1,952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #!/bin/sh
  2. md5=
  3. file="${1:-Recovery.log}"
  4. while :; do
  5.     sleep 1
  6.     _md5=$( md5 "$file" | awk '{print $NF}' )
  7.     [ "$md5" != "$_md5" ] || continue
  8.     pos=$( awk '/current/{getline;print $1}' "$file" )
  9.     line=$( awk -v pos=$pos '$1==pos{line=NR}END{print line}' "$file" )
  10.     lc=$( wc -l "$file" | awk '{print $1}' )
  11.     pct="?"
  12.     [ $line -le 4 ] || pct=$( echo "scale=2;$line*100/$lc" | bc )
  13.     printf "%s @%d/%d %s (%.2f%%) %s\n" \
  14.         "$( date )" "$line" "$lc" "$pos" "$pct" "$file"
  15.     md5="$_md5"
  16. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement