You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash# robustnessset -euo pipefail
# Verify that at least one file exists before proceeding for each typeshopt -s nullglob
sudo apt install moreutils
# Function to add headers only if they don't existadd_header_if_not_exists() {
local filename=$1local header=$2# Check if header already existsif! head -n 1 "$filename"| grep -q "^${header}$";then
{ echo"$header"; cat "$filename"; } | sponge "$filename"fi
}
# Add headers to hosts-* files
hosts_files=(hosts-*.csv)
if [ "${#hosts_files[@]}"-gt 0 ];thenforfilenamein"${hosts_files[@]}";do
add_header_if_not_exists "$filename""\"host\",\"tps\",\"tps_miss\""donefi# Add headers to apps-* files
apps_files=(apps-*.csv)
if [ "${#apps_files[@]}"-gt 0 ];thenforfilenamein"${apps_files[@]}";do
add_header_if_not_exists "$filename""\"app\",\"tps\",\"tps_miss\""donefi# Add headers to country-* files
country_files=(country-*.csv)
if [ "${#country_files[@]}"-gt 0 ];thenforfilenamein"${country_files[@]}";do
add_header_if_not_exists "$filename""\"country\",\"ips\",\"tps\",\"tps_miss\""donefi
The text was updated successfully, but these errors were encountered:
On norbert, run:
The text was updated successfully, but these errors were encountered: