|
#!/bin/bash |
|
|
|
|
|
for csv_file in *.csv; do |
|
|
|
if [ -f "$csv_file" ]; then |
|
echo "Processing $csv_file..." |
|
|
|
|
|
temp_file=$(mktemp) |
|
|
|
|
|
if head -1 "$csv_file" | grep -q "Submitted By"; then |
|
echo "The 'Submitted By' column already exists in $csv_file." |
|
continue |
|
fi |
|
|
|
|
|
awk -v OFS="," 'NR==1 {print $0, "Submitted By"} NR>1 {print $0, "Baseline"}' "$csv_file" > "$temp_file" |
|
|
|
|
|
mv "$temp_file" "$csv_file" |
|
|
|
echo "Column 'Submitted By' added successfully with 'Baseline' entry in each row for $csv_file." |
|
fi |
|
done |
|
|
|
echo "All CSV files processed." |
|
|