Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
953 B
1
Indexable
Never
#!/bin/bash

#Define the variables

tampered_files=

declare -A tampered_dept_files


for dept_dir in logs/*; do
    dept_name=$(basename "$dept_dir") 



    for log_file in "$dept_dir"/*.log; do

    if ! date -d "$(basename "$log_file" .log | sed 's/_/ /g')" >/dev/null 2>&1; then

    echo "Tampered file: $log_file"

    ((tampered_files++))

    ((tampered_dept_files[$dept_name}++))

    continue
    fi


    if [[ "$(head -n 1 "$log_file")" != "$dept_name" || "$(head -n 2 "$log_file" | tail -n 1)" != "$(basename "$log_file" .log | sed 's/_/-/g')" ]]; then

    echo "Tampered file: $log_file"

    ((tampered_files++))

    ((tampered_dept_files[$dept_name]++))

    fi
    done
done


echo "Total number of tampered files: $tampered_files"

for dept_name in "${!tampered_dept_files[@]}"; do

    echo "Number of tampered files in $dept_name department: $(tampered_dept_files[$dept_name]}"

done