|
|
|
@ -63,11 +63,6 @@ hash_files () { |
|
|
|
|
create_csv () { |
|
|
|
|
#echo "=== Create array of comma-separated-values. === |
|
|
|
|
#==================================================" |
|
|
|
|
csv_columns=( "File Path" "File Hash" ) |
|
|
|
|
for key in ${keys_of_interest[@]};do |
|
|
|
|
csv_columns+=( ${keys_of_interest[key]} ) |
|
|
|
|
done |
|
|
|
|
IFS=',';echo "${csv_columns[*]}";IFS=$'\n' |
|
|
|
|
# for i in ${!list_of_files[@]}; do |
|
|
|
|
# csv_array+=( ${list_of_files[i]},${list_of_hashes[i]} ) |
|
|
|
|
# done |
|
|
|
@ -78,10 +73,19 @@ create_csv () { |
|
|
|
|
write_data () { |
|
|
|
|
#echo "=== Write data to a .csv file. === |
|
|
|
|
#====================================" |
|
|
|
|
## Create temp file |
|
|
|
|
temp_csv_file=$($mktemp_bin) |
|
|
|
|
printf '%s,%s\n' "File Path" "File Hash" >> $temp_csv_file |
|
|
|
|
for line in ${csv_array[@]};do |
|
|
|
|
printf '%s\n' $line |
|
|
|
|
## Initialize column names |
|
|
|
|
csv_columns=( "File Path" "File Hash" ) |
|
|
|
|
## Populate Columns from keys of interest |
|
|
|
|
for key in ${keys_of_interest[@]};do |
|
|
|
|
csv_columns+=( ${keys_of_interest[key]} ) |
|
|
|
|
done |
|
|
|
|
## Print columns to first line of csv |
|
|
|
|
IFS=',';echo "${csv_columns[*]}";IFS=$'\n' >> $temp_csv_file |
|
|
|
|
## Print csv array rows following columns row |
|
|
|
|
for row in ${csv_array[@]};do |
|
|
|
|
printf '%s\n' $row |
|
|
|
|
done >> $temp_csv_file |
|
|
|
|
# cat $temp_csv_file |
|
|
|
|
write_log "$temp_csv_file written successfully." |
|
|
|
|