Search code examples
bashwhois

Whois scraping bash script—if clause errors


I wrote a fairly straightforward script to map out what one-word domains are still available. I'm getting an error in line 7, the if clause, but I can't see anything wrong with it.

#!/bin/bash

for i in $(cat /usr/share/dict/words);
do
        i="$i.com"
        echo $i processing `date`
        if [ $(whois $i) == "*No match for*" ]
        then
                echo $i AVAILABLE
#               echo "$i">>domains.available.`date "+%Y%m%d"`
        else
                echo $i unavailable
#               echo "$i">>domains.unavailable.`date "+%Y%m%d"`
        fi
done

I looked up similarly straightforward scripts online, and they seem syntactically identical.


Solution

  • Try double brackets and the * outside the quotes

    if [[ $(whois $i) == *"No match for"* ]]