Я бы сделал это так (подробности см. В комментариях к коду):
#!/usr/bin/env bash
# Servers file
declare -r servers='servers'
# Prepare the CSV output file
declare -r csv_out='/tmp/check_var2.csv'
rm -f "$csv_out"
# Print the first CSV line with headers
echo 'Filesystem,Size,Used,Avail,Use%,Mounted on,Hostname' >"$csv_out"
# Prepare commands script sent to remote servers via ssh
# Produces CSV data:
# Filesystem,Size,Used,Avail,Use%,Mounted on,Hostname
declare -- ssh_script
IFS= read -r -d '' ssh_script <<'EOF'
{
df -h /var | tail -n 1
hostname
} | xargs | tr ' ' ','
EOF
typeset -r ssh_script
# Fills the servers_array from the servers file
declare -a serv_array
IFS=$'\n' read -r -d ' ' -a serv_array <"$servers"
# Get the size of the servers array
declare -ri serv_size="${#serv_array[@]}"
# Fixed progress-bar version
progress_bar() {
local -r width=40
local bar
local left
# Build string lengths
printf -v bar "%$((${1}*width/${2}))s"
printf -v left "%$((width-${1}*width/${2}))s"
# Build and print the progress bar
# Output example: [########################################] 100%
printf "\rProgress : [%s%s] %d%%" "${bar// /#}" "${left// /-}" $((${1}*100/${2}))
}
# Iterate index of servers
for ((i = 0; i < serv_size; i++)); do
server="${serv_array[i]}"
ssh \
-o "BatchMode=yes" \
-o StrictHostKeyChecking=no \
"$server" \
"$ssh_script" \
>>"$csv_out"
progress_bar "$((i + 1))" "$serv_size"
done
echo