-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbyrm
More file actions
executable file
·42 lines (32 loc) · 789 Bytes
/
byrm
File metadata and controls
executable file
·42 lines (32 loc) · 789 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
39
40
41
42
#!/bin/bash
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
removeFile() {
FILE=$1
if [ ! -e "$FILE" ] && [ ! -h "$FILE" ] ; then
echo "File '$FILE' doesn't exists"
exit 1
fi
for i in $(ls ~/.bysync/*.conf) ; do
source "$i"
if [ "${FILE:0:${#SRC}}" == "$SRC" ]; then
FILE_IN=${FILE:${#SRC}}
DST_DIR=${DST#*:}
DST_HOST=${DST%:*}
ssh "$DST_HOST" "rm -rf \"$DST_DIR/$FILE_IN\"" && \
rm -rf "$FILE"
return
fi
done
echo "Directory for '$FILE' not found in bysync configs"
exit 1
}
if [ $# -eq 0 ] ; then
echo "$0 <file>"
exit 1
fi
for FILE in "$@" ; do
FILE=$(realpath "$FILE")
removeFile "$FILE"
done