#!/bin/bash
date
exec 3<> /usr/dict/words
while read line <&3; do
echo $line | awk '/read/{print $1}'
done
exec 3>&-
date
while read line ; do
echo $line | awk '/read/{print $1}'
done < /usr/dict/words
date
输出如下:
Sat Mar 7 09:58:46 CST 2009
already
bedspread
beebread
bread
breadboard
breadfruit
breadroot
breadth
breadwinner
cornbread
dread
dreadful
dreadnought
Eveready
lipread
proofread
read
readout
ready
spread
thread
threadbare
tread
treadle
treadmill
widespread
Sat Mar 7 10:02:00 CST 2009
already
bedspread
beebread
bread
breadboard
breadfruit
breadroot
breadth
breadwinner
cornbread
dread
dreadful
dreadnought
Eveready
lipread
proofread
read
readout
ready
spread
thread
threadbare
tread
treadle
treadmill
widespread
Sat Mar 7 10:07:53 CST 2009
第一种方法耗时3分14秒,第二种方法5分53秒,节省了将近一半时间。
参考文献:
阅读(1344) | 评论(0) | 转发(0) |