cat domains.txt google.com domains.com gmail.com yahoo.com
#!/bin/bash DOMAINS=`cat domains.txt` HTTP1="" for domain in $DOMAINS ; do code=`curl -I $domain 2>/dev/null | grep HTTP | awk '{print $2}'` if [ ! -z $HTTP1 ];then HTTP1+="|" fi HTTP1+="$domain:$code" done echo $HTTP1 IFS='|' readarray -d '|' ARR <<< $HTTP1 # arraylength=${#ARR[@]} for (( i=1; i<${arraylength}+1; i++ )); do echo $i ${ARR[$i-1]} done