Created
February 11, 2012 13:10
-
-
Save brokendish/1799354 to your computer and use it in GitHub Desktop.
順番に説明とかしてみる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
①grep 'ABC' /home/hoge/apache404log.txt | | |
②awk '{print $1}' | | |
③sort | | |
④uniq | | |
⑤xargs -I{} whois {} | | |
⑥grep -i country | | |
⑦sed 's/ //g' | | |
⑧sort | | |
⑨uniq | |
⑩>ABC_country.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
①「apache404log.txt」テキストファイルから「ABC」の文字がある行だけを抜き出す
②awk(※1)というコマンド(スクリプト言語)で行の最初の単語(IPアドレス)を抜き出す
③並び替える(昇順)※④で重複行を除く為
④重複行を除く※⑤で不要な処理をさせない為
⑤whoisコマンド(※2)に1行ずつ引数として渡す
⑥whoisコマンドの結果から「country」の文字がある行だけ抜き出す
⑦sedコマンド(※3)で空白文字を削除する
⑧並び替える(昇順)※⑨で重複行を除く為
⑨重複行を除く※⑩で重複した余分なものを出力しない為
⑩ABC_country.txtとして保存する