-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlsdups
executable file
·48 lines (37 loc) · 1.06 KB
/
lsdups
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
43
44
45
46
47
48
#! /bin/bash
printargs(){
while [ $# -gt 0 ]; do
echo "$1"
shift
done
}
if [ "$1" == "--no-ls" ]; then
shift
else
echo ll2lpath: >&2
ll2lpath "$@"
fi
#echo lsdups arguments:
#printargs "$@"
#echo .
#exit
if [ $# == 0 ]; then
wd=.files
mkdir -p "$wd"
else
wd="$1"
shift
fi
files="$(ls -1 "$wd"/20*-files "$wd"/19*-files "$wd"/21*-files 2>/dev/null | sort -r | head -n 1)"
[ -z "$files" ] && echo lsdups: can not get files file >&2 && exit 1
#printargs "$files" "$wd"/hashes
datetime=$(date '+%F_%H-%M-%S')
[ -f "$wd"/rmdups.bash ] && mv "$wd"/rmdups.bash "$wd/rmdups.bash_$datetime" && bak=1
runcpp -o '-std=gnu++11 -O3' lsdups-internal.cpp "$files" "$wd"/hashes > "$wd"/rmdups.bash || { echo rmdups not created; exit 1; }
chmod +x "$wd"/rmdups.bash
if [ -s "$wd"/rmdups.bash ]; then
grep '^\(f(){ #====\|#----\)' "$wd"/rmdups.bash
else
echo дублирующиеся файлы отсутствуют
fi
[ "$bak" = 1 ] && echo старый rmdups.bash перемещен в \""$wd/rmdups.bash $datetime"\" || echo нету старого rmdups.bash