Skip to content

Instantly share code, notes, and snippets.

@akissu
Created March 11, 2016 23:57
Show Gist options
  • Save akissu/9a63679c036af2aa2185 to your computer and use it in GitHub Desktop.
Save akissu/9a63679c036af2aa2185 to your computer and use it in GitHub Desktop.
Shell script that performs a cp of source to destination and watches the process.
#!/bin/sh
CPFILEPATH=`readlink -f $1`
CPDSTPATH=`readlink -f $2`
CPFILESIZE=`stat --printf "%s" $1`
echo $CPFILEPATH: $CPFILESIZE Bytes
echo cp $CPFILEPATH $CPDSTPATH/. "&"
cp $CPFILEPATH $CPDSTPATH/. &
CPPID=`echo $!`
watch -n1 "cat /proc/$CPPID/fdinfo/* | grep pos| tail -n1 | awk '{print \$2,\"\\n$CPFILESIZE\"}'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment