Dropping redundant path from hash output

hash-each-file
Mike Holloway 3 years ago
parent eb629b225c
commit 7745cd6152
  1. 18
      hash-files

@ -25,6 +25,12 @@ unset IFS
hash_files () {
echo "=== Hash files. ===
======================"
IFS=$'\n'
for file in ${list_of_files[@]}; do
hash=$(md5sum $file | awk '{ print $1 }')
list_of_hashes+=( $hash )
done
unset IFS
}
create_csv () {
@ -48,11 +54,17 @@ trap cleanup EXIT
echo "Main Start"
create_list_of_files
for file in ${list_of_files[@]}; do
echo $file
done
write_log
hash_files
if [ ${#list_of_files[@]} != ${#list_of_hashes[@]} ];then
echo "Error! Number of files and hashes differs. Exiting..." && exit
else
for i in ${!list_of_files[@]}; do
echo "/==============================/
File: ${list_of_files[i]}
Hash: ${list_of_hashes[i]}"
done
fi
write_log
create_csv
write_log

Loading…
Cancel
Save