Check bash version

rm /tmp/out.log
for HOST in $(cat host.list); do
VERSION=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=3 ${HOST} 'dpkg-query -W -f="\${Version}" "*bash*"')
[ ! -z ${VERSION} ] && echo "${HOST} ${VERSION}" | tee -a /tmp/out.log
done

# squeeze-lts
sed -i 's|4.1-3+deb6u2|4.1-3+deb6u2_OK|g' /tmp/out.log

# wheezy
sed -i 's|4.2+dfsg-0.1+deb7u3|4.2+dfsg-0.1+deb7u3_OK|g' /tmp/out.log

# lenny
sed -i 's|3.2-4|3.2-4_LENNY|g' /tmp/out.log

# etch
sed -i 's|3.1dfsg-8|3.1dfsg-8_ETCH|g' /tmp/out.log

# check
cat /tmp/out.log | grep -v OK | grep -v LENNY | grep -v ETCH

# view versions
cat /tmp/out.log | grep -v OK | cut -d " " -f2 | sort -u

# view version count
for VERSION in $(cat /tmp/out.log | grep -v OK | cut -d " " -f2 | sort -u); do
printf "%-20s %s\n" "${VERSION}" "$(grep -c ${VERSION} /tmp/out.log)x"
done

# check git version
for HOST in root@www1.example.com root@www2.example.com root@www2.example.com; do
echo "*${HOST#*@}*"

echo -n "Distribution: "
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=3 ${HOST} cat /etc/apt/sources.list | grep main | head -1 | cut -d " " -f3

echo -n "Git: "
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=3 ${HOST} 'dpkg-query -W -f="\${Version}" "git"'
echo
echo
done