-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopyWithProgress.sh
More file actions
executable file
·38 lines (38 loc) · 995 Bytes
/
copyWithProgress.sh
File metadata and controls
executable file
·38 lines (38 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Script that does a cp, but it gives you progress while it's copying.
# John Hakala, 1/20/2016 (but written a while ago)
if [ "$#" -ne 2 ]; then
echo "inb4 you forgot teh sauce and target directories."
kill -INT $$
else
filename=$(basename $1)
if [[ -d $2 ]]; then
if [[ -f ${2}/${filename} ]]; then
echo "${2}/${filename} already exists, lulz."
kill -INT $$
else
echo "Copying ${filename} to directory $2"
rsync -ah --progress $1 ${2}/${filename}
if [ "$?" -ne 0 ]; then
echo "copying got pwned."
kill -INT $$
else
echo "Copy succeeded."
fi
fi
else
if [[ -f $2 ]]; then
echo "$2 already exists, nub. Use fpcp to force overwrite it."
kill -INT $$
else
echo "Copying ${filename} to $2"
rsync -ah --progress $1 ${2}
if [ "$?" -ne 0 ]; then
echo "Copy wuz teh fail."
kill -INT $$
else
echo "Copy succeeded."
fi
fi
fi
fi