參考:
http://my.huhoo.net/archives/2007/08/perl_1.html
簡單的
echo "tt" |perl -ne 'print $_ '
多行
find . -type f |perl -ne 'print $1 $_ if $_=~ /(.*)flv/'
限定行數
find . -type f |perl -ne 'print $_ if $_=~ /.*flv/ && $tmp++<10 && $tmp>4'
#當然shell>> find . -type f |grep ".*flv" |sed -n '5,10p' 和上面是一樣的
# 不過 你看那 其中使用 $1 等正則重定向 ,哈哈
結果大體上
./test3/0.flv
./flvplayer.swf
./test.flv
./0.flv
perl -h
-e program one line of program (several -e's allowed, omit programfile)
-n assume "while (<>) { ... }" loop around program
-p assume loop like -n but print line also, like sed
整理 www.aygfsteel.com/Good-Game