> For the complete documentation index, see [llms.txt](https://kawsing.gitbook.io/opensystem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled-4/shell-script/host-+-whois-zhao-chu-mou-wang-zhan-de-zi-xun.md).

# host + whois找出某網站的資訊

執行以下命令

```
ip=host tw.yahoo.com | grep 'address' | head -1 | awk '{ print $4}'
whois $ip
```

編寫shell

```bash
#!/bin/bash
#取得所有參數
domarg=$@
[ $# -eq 0 ] && { echo "使用: $0 domain1.xxx domain2.xxx ..."; exit 1; }
for dom in $domarg
do
        echo "--------------- $dom 的資訊----------------"
        echo ""
        ip=$(host $dom | grep 'address' | head -1 | awk '{ print $4}')
        [ "$ip" == "" ] && { echo "Error: $dom 不存在或dns解析有誤 ."; continue; }
        echo "取得資訊中....=>$dom [ $ip ]"
        whois "$ip" 
        echo "----------------end-----------------"
done 
```

./domaininfo kawsing.gitbook.io tw\.yahoo.com [www.google.com](http://www.google.com)
