next up previous
: awk : UNIX $B$N%F%-%9%H!&%U%!%$%k=hM}(B : $BI8=`F~=PNO$N%j%@%$%l%/%7%g%s!"%Q%$%W(B

$B%U%#%k%?!<(B

$B$^$:0J2<$N=`Hw$r$7$F$+$i!"$=$N8e$NA`:n$r$7$h$&!#(B ( tcsh $B$N@_Dj$,$^$@$N?M$O!"(B tcsh $B$H%?%$%W$7$F!"(B tcsh $B$r5/F0$7$F$+$i


 waltz11%   cd 		  $B%[!<%`%G%#%l%/%H%j%#$K0\F0$9$k!#(B

waltz11% mkdir filter filter $B$H$$$&L>A0$N%G%#%l%/%H%j%#$r:n$k!#(B
waltz11% cd filter filter $B$K0\F0$9$k!#(B
waltz11% ln -s ~re00018/gutenberg/* .
~re00018/gutenberg $B$K$"$k%U%!%$%k$K%7%s%\%j%C%/!&%j%s%/$rD%$k!#(B
waltz11% ls $B$I$&$$$&%U%!%$%k$,$"$k$+!"3NG'$9$k!#(B
alice29.txt $B$J$I$N%U%!%$%kL>$,8+$($k$O$:!#(B
waltz11% cat LIST LIST $B$NCf?H$r8+$k!#(B

$B:#2sG[I[$7$?%U%!%$%k(B ($B0J2<$G$O(B Gutenberg $B%F%-%9%H$H8F$V$3$H$K$9$k(B) $B$N=P=j$K$D$$$F$O!"IUO?(B A. $B!V8EE5(B ($BJ8=q(B) $B$NEE;R2=!W$r;2>H$7$F$[$7$$!#(B

UNIX $B%7%9%F%`$G$O!"I8=`F~=PNO$N%j%@%$%l%/%7%g%s!"(B $B%Q%$%W5!G=$r3hMQ$9$k$?$a!"(B

$BI8=`F~NO$+$iF~NO$7!"I8=`=PNO$K=PNO$7!"B>$NF~=PNO$O;H$o$J$$$G:Q$`(B
$B$H$$$&%3%^%s%I$,B?$$!#(B $B$3$N$h$&$J%W%m%0%i%`$r(B$B%U%#%k%?!<(B$B$H8F$V!#(B $B%U%#%k%?!<$O4JC1$J5!G=$7$+;}$?$J$$$b$N$,B?$$$,(B
$BJ#?t$N%U%#%k%?!<$r%Q%$%W$G@\B3$7$FJ#;($J;E;v$,=PMh$k(B
$B$h$&$K$J$C$F$$$k(B2$B!#(B

$B0J2R2p$9$k!#(B

grep
$B%F%-%9%H!&%U%!%$%k$+$i;XDj$7$?J8;zNs$r8!:w$7$F!"$=$l$r4^$`9T$rI=<($9(B $B$k!#(B
$B!!8!:w$KMQ$$$k%Q%?!<%s$N;XDj$K$O!"(B$B@55,I=8=(B (regular expression3) $B$H8F$P$l$k7A<0$,MxMQ$G$-$k(B ( grep $B$NL>A0$NM3Mh$O(B global/regular-expression/print)$B!#(B
sort
$B%F%-%9%H%U%!%$%k$r9TC10L$G!"=g=xIU$1$F(B($BDL>o$O%"%k%U%!%Y%C%H=g$K(B)$BJB(B $B$YJQ$($k!#(B
  • -r     $B5U=g$KJB$Y$k!#(B
  • -n     $B?tCM$H$7$F$NBg>.$GJB$YJQ$($k!#(B
  • +$x$ ($x$ $B$O@0?t(B)     $BBh(B $x$ $B%U%#!<%k%I$NMWAG$NBg>.$GJB$Y$k!#(B
$BNc$($P!"%[!<%`%G%#%l%/%H%j%#$K$"$k%U%!%$%k$r!"(B $B%5%$%:$,Bg$-$$=g$K%j%9%H$9$k$K$O!"(B

 ls -l ~ | sort +4 -n -r
($B$3$3$G$O!"(B ls -l ~ $B$N=PNO$NBh(B5$B%U%#!<%k%I$K$O%U%!%$%k$N%5%$%:$,$"$k!"(B $B$H2>Dj$7$F$$$k!#(B)
wc
$B%F%-%9%H!&%U%!%$%kCf$N9T?t!"C18l?t!"J8;z?t$r?t$($k!#(B

 wc alice29.txt
uniq
$BO"B3$9$kF1$8FbMF$N9T$r(B1$B$D$K$^$H$a$k!#(B
-c $B$H$9$k$H!"F1$89T$,2?9TB3$$$?$+I=<($9$k!#

 cat alice-words | sort | uniq -c | sort -n

$B0lBN2?$r$d$C$F$$$k$N$+(B? $B0lCJ0lCJ3NG'$7$J$,$i%A%'%C%/$7$h$&!#(B
$BD9$$(B $B%3%^%s%I$O%7%'%k!&%9%/%j%W%H(B4 $B$K$9$k$HJXMx$G$"$k!#(B

 cat top20 

top20 alice-words
/usr/ucb/tr
$BJ8;zC10L$NCV49!":o=|$r9T$&!#(B
/usr/ucb/tr [ -cds] [$BJ8;zNs(B1 [$BJ8;zNs(B2]]
  • -d $B$O:o=|$9$k$3$H$rI=$9!#(B
  • -s $B$OF1$8;z$,O"B3$7$?>l9g!"0l;z$KCV49$9$k$3$H$rI=$9!#(B
  • -c $B$O%Q%?!<%s$K4^$^$l$J$$J8;z$rBP>]$K$9$k!#(B
$B%Q%?!<%s$K$OJ8;z%3!<%I$r(B 8 $B?J?t$G;XDj$G$-$k(B ($B0J2<$NNc$r;2>H(B) 5 $B!#$^$?J8;z$NHO0O$r(B - $B$G;XDj$G$-$k!#(B A-Z $B$G(B ` A' $B$+$i(B ` Z' $B$^$G$NJ8;z(B ($B$D$^$j1QBgJ8;z(B) $B$rI=(B $B$9!#(B
\begin{itembox}[l]{BSD UNIX $B$N(B tr ({\tt /usr/ucb/tr})}\footnotesize\begin{tabbin...
...$BNJ8;z$r2~9T$KJQ49!(B\\
\> $B

\begin{itembox}[l]{System V $B$N(B tr}\footnotesize\begin{tabbing}
xxxxxxxxxxxxxxxxx...
...$BNJ8;z$r2~9T$KJQ49!(B\\
\> $B
$B>e5-$N(B alice-words $B$H$$$&%U%!%$%k$O cat alice29.txt | /usr/ucb/tr -cs A-Za-z '\012' > alice-words
$B$@$+$i!"C18l$N=P8=IQEYI=$rF@$k$?$a$K!"

 cat alice29.txt | /usr/ucb/tr -cs A-Za-z '\012' | sort | uniq | sort -n
head
$B:G=i$N?t9T$N$_I=<($9$k%3%^%s%I!#(B
$B%*%W%7%g%s$r;XDj$7$J$$$H:G=i$N(B 10 $B9T$rI=<($9$k!#(B -$x$ $B$H$9$k$H:G=i$N(B $x$ $B9T$rI=<($9$k!#(B

 head -30 /usr/dict/words 		  /usr/dict/word $B$N@hF,$+$i(B $30$ $B9T$rI=<($9$k!#(B

( /usr/dict/words $B$O1QC18l$rG<$a$?%U%!%$%k$G$"$k!#(B)
tail
$B%F%-%9%H$N:G8e$NJ}$rI=<($9$k%3%^%s%I!#(B
$B%*%W%7%g%s$r2?$b;XDj$7$J$$$H(B 10 $B9T$N$_I=<($9$k!#(B -$x$ $B$H$9$k$H(B $B:G8e$N(B $x$ $B9T$rI=<($9$k!#(B +$x$ $B$H$9$k$H!":G=i$N(B $x$ $B9T$r=|$$$?;D(B $B$j$rI=<($9$k!#(B

 cat sawyr10.txt | tail -30 		  sawyr10.txt $B$N:G8e$N(B 30 $B9T$rI=<($9$k!#(B
nkf
$BF|K\8l$NJ8;z%3!<%I(B($B4A;z%3!<%I(B)$B$NJQ49$r$9$k!#(B
  • -e $BF|K\8l(B EUC $B$KJQ49$9$k!#(B
  • -s $B%7%U%H!&%8%9$KJQ49$9$k!#(B
  • -j JIS $B4A;z%3!<%I$KJQ49$9$k!#(B
  • -v $B;H$$J}$N4JC1$J@bL@$rI=<($9$k!#(B
$BpJs2J3X%;%s%?!<$N%o!<%/%9(B $B%F!<%7%g%s$GMxMQ$G$-$k$h$&$KJQ49$G$-$k(B ($BJ8;z%3!<%I$rF|K\8l(B EUC $B$KJQ49(B $B$7!"(BCR, C-z $B$r:o=|(B)$B!#(B

 nkf -ed $B%U%!%$%kL>(B   | tr -d "\032" > $B?7$7$$%U%!%$%kL>(B

$B$^$?!"

 nkf -sc $B%U%!%$%kL>(B  > $B?7$7$$%U%!%$%kL>(B

($B$?$@$7!"%F%-%9%H!&%U%!%$%k$N7A<0$NJQ49$NL\E*$@$1$J$i$P!"(B /usr/meiji/pub/bin/ $B$K$"$k(B qkc $B$H$$(B $B$&%3%^%s%I$,JXMx$+$bCN$l$J$$!#(B qkc -euz $B%U%!%$%kL>(B $B$G%o!<%/%9%F!<%7%g%s7A<0$K!"(B qkc -ms $B%U%!%$%kL>(B $B$G(B Winwos $B7A<0$K$J$k!#(B qkc -H $B$G%X%k%W$,8+$($k!#(Bqkc $B$K$O(B Windows $BHG$b$"$k!#(B)
sed
$BJ8;zNs$NCV49$J$I!";X<($K=>$C$FJT=8$9$k%3%^%s%I(B ($BM-L>$@$1$I!":#2s$OL>(B $BA0$@$1>R2p(B)$B!#(B
(nkf $B$K$D$$$F$O!"(B $BA02s$N%W%j%s%H$K:GDc8B$N$3$H$O@bL@$7$?$N$G!"$3$3$G$ON,$9$k!#(B)


next up previous
: awk : UNIX $B$N%F%-%9%H!&%U%!%$%k=hM}(B : $BI8=`F~=PNO$N%j%@%$%l%/%7%g%s!"%Q%$%W(B
Masashi Katsurada $BJ?@.(B12$BG/(B6$B7n(B30$BF|(B