if statement - Bash Script - Not returning column/variable -
if statement - Bash Script - Not returning column/variable -
i having issue cant seem figure out after couple hours of tinkering this. cant seem script homecoming final column.
#!/bin/bash file="/users/user12/desktop/url-list.txt" log="/users/user12/desktop/url-results.txt" fmt="%-25s%-12s%-16s%-20s\n" printf "$fmt" domain_name http_code response_time content_check > "$log" while read line read code time < <(curl -o /dev/null --silent --head --write-out '%{http_code} %{time_total}' "$line") curl "$line" 2>/dev/null > /users/user12/desktop/domainquerystring_output.txt ifstatementconditional=`grep "the content i'm looking verify" /users/user12/desktop/domainquerystring_output.txt | wc -l` if [ $ifstatementconditional -eq 1 ] ; second_check="online" else second_check="domain offline" fi printf "$fmt" "$line" "$code" "$time" "$second_chance" >> "$log" done <"$file"
it returns next nil final column....
domain_name http_code response_time content_check google.com 301 1.177
thanks help guys. help much appreciated.
you have "$second_chance" should have had "$second_check". other that, next improve way if
check:
if grep "the content i'm looking verify" $yourfile -q ... else ... fi
bash if-statement
Comments
Post a Comment