Created
September 7, 2014 16:51
-
-
Save syui/cd6fd9765bf89644843d 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
#!/bin/zsh | |
sfile=${0:a:t} | |
case $1 in | |
-[hH]|-[hH]elp) | |
echo " | |
引数1...ファイル名 | |
引数2...キーワード1 | |
引数3...キーワード2 | |
$ ./$sfile httpd-access.log Moz Chr | |
" | |
;; | |
*) | |
case $# in | |
1) | |
cat $1 | |
;; | |
2) | |
for i in `cat $1 | tr ' ' '\n' | nl -n ln | grep $2 | cut -d ' ' -f 1`;do cat $1 | cut -d ' ' -f $i- ;done | |
;; | |
3) | |
key1=`cat $1 | tr ' ' '\n' | nl -n ln | grep $2 | awk 'NR==1' | cut -d ' ' -f 1` | |
key2=`cat $1 | tr ' ' '\n' | nl -n ln | grep $3 | awk 'NR==1' | cut -d ' ' -f 1` | |
cat $1 | cut -d ' ' -f $key1-$key2 | |
;; | |
*) echo no var;; | |
esac | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment