代码: 全选
#!/bin/sh
#
search=compact.php
#
#
# w3m -no-cookie -dump http://dict.cn/${search}?q=$1 > /tmp/tmp.htm
# A=$(sed -n '$=' /tmp/tmp.htm)
# sed $(($A-1)),${A}d /tmp/tmp.htm|sed -n '3,$p'
#
#
w3m -nocookie -dump http://dict.cn/${search}?q=$1 | tac | sed '1,2d' | tac | sed -n '3,$p'

....作为小工具,只是 简单地 把文本处理了一下


注释掉的部分是把文件放到tmp下来处理,避免使用tac,可能会省些内存?

保存为dic,chmod +x dic,复制到/usr/local/bin下,执行结果如下:

新加了-no-cookie选项,去除禁用cookie的提示信息[simsilver myhost ~]$ dic dictionary
dictionary ['dikʃənəri] 生词本
n. 词典,字典,辞典
例句与用法:
1. Dictionary writers must be skilled in the art of definition.
词书编纂者必须精於给词语下定义的技巧.
2. That is not, properly speaking, a dictionary but a grammar book.
严格地说,那不是一本字典,而是一本语法书。
3. The poet minted several words that cannot be found in any dictionary.
诗人造了几个词典里找不到的词。
4. That dictionary belongs to me.
那本字典是属于我的。
5. This dictionary is available in electronic version.
这部词典有电子版。
6. He is, as it were, a walking dictionary.
他可说是个活字典。
7. A dictionary is an invaluable aid in learning a new language.
在学习一种新语言时,词典是非常有用的工具。
8. Please pass the dictionary to me.
请把字典递给我。
[simsilver myhost ~]$