Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(): Failed opening '/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24
如何透過shell script來做domain name的篩選 – unethost無限空間虛擬主機 技術分享部落格

如何透過shell script來做domain name的篩選

如果從cpanel WHM抓出所有主機的域名(domain name)時,往往會發現,子域名(sub domain) 和頂層域名(top level domain) 是混雜的。

這時候,可以用基本的sed來做篩選。做法如下:
在一個文字檔 list 裡放所有的域名,例如:

aa.bb.com
cc.net
1123.org
1aa.bbcd.com

下指令:
cat list | sed -e “/[^\.]*\.[^\.]*\.[^\.]*/d” | sort

即可抓出所有想要的top level domain。( 這個指令的功能就是把所有的sub domain刪去而已。)