blob: 76a2571dc2ba05ee3b83cee214337760ddb84bdd (
plain) (
blame)
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
|
#!/usr/bin/env sh
# Description: Create and verify md5 checksums
#
# If selection is used: it will generate one md5 file containing the checksums and file names
# [with paths if they are in another directory]
# If file is used: if the file is .md5 file, then it does the check
# if the file is not .md5 file, it creates the md5 file from it
#
# Shell: POSIX compliant
# Author: ath3
selection=~/.config/nnn/.selection
resp=f
if [ -s "$selection" ]; then
echo -n "work with selection (s) or current file (f) [default=f]: "
read resp
fi
if [ "$resp" = "s" ]; then
file=$(basename "$(cat $selection | tr '\0' '\n' | head -n 1)").md5
cat "$selection" | sed 's|'"$PWD/"'||g' | xargs -0 -i md5sum {} > "$file"
else
if ! [ -z "$1" ] && [ -f "$1" ]; then
if [ $(echo $1 | grep \.md5$) ]; then
cat "$1" | md5sum -c
read
else
file=$(basename "$1").md5
md5sum "$1" > "$file"
fi
fi
fi
|