m5dsum list utility
This commit is contained in:
34
files/md5sum-update
Executable file
34
files/md5sum-update
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
function helpexit() {
|
||||
echo Add more files in md5sum list
|
||||
echo 'Usage: m5sum-update [list name]'
|
||||
echo 'list name is md5sums.txt by default'
|
||||
exit
|
||||
}
|
||||
|
||||
[[ "$1" = "-h" ]] && helpexit
|
||||
list_name="$1"
|
||||
[[ -z "$1" ]] && list_name="md5sums.txt"
|
||||
|
||||
test -f "$list_name" || touch "$list_name"
|
||||
|
||||
for file in *; do
|
||||
if [ $file = $list_name ]; then
|
||||
continue
|
||||
fi
|
||||
if test -d "$file"; then
|
||||
echo $file is a directory
|
||||
continue
|
||||
fi
|
||||
if test -f "$file"; then
|
||||
if grep -q " $file$" $list_name; then
|
||||
echo "$file already added"
|
||||
else
|
||||
echo "$file adding..."
|
||||
md5sum "$file" >> "$list_name"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
sort -k 2 -o "$list_name" "$list_name"
|
||||
Reference in New Issue
Block a user