I have multiple CSV files with the next format:
"name","last_name","birth_day","register_date"
Michael,Jackson,August 29 - 1958,August 29 - 1958
Claude,Shannon,April 30 - 1916,April 30 - 1916
I want to transform each file to the next format:
"name","last_name","birth_day","register_date",sha256
Michael,Jackson,August 29 - 1958,August 29 - 1958,9949a1af67a3fb465eca01ca884f5ec7cd280078a39a0430a0f352bf19e16685 -
Claude,Shannon,April 30 - 1916,April 30 - 1916,fb464b3ab4f3f3db2384e192135cde97486ce96fe34e391a3294e5076f800aae -
That means I want to add the "sha256" column with the hash values.
So far I could get the hash values for each row but I don't know how to add this value as a column "sha256" to the CSV file.
for file in ${DIR}/csv/*
do
while IFS='' read -r line || [[ -n "$line" ]]; do
echo -n $line | shasum -a 256
/**
Here it calculates the hash per row, and I want to add it
at the end of the row as "sha256" column
**/
done < "$file"
done
How can I do it?