Merge pull request #621 from geekpi/master

[Translated]look : Linux Command To Verify Spellings And Display Lines Beginning With A String
This commit is contained in:
tinyeyeser 2014-01-01 00:53:18 -08:00
commit ce92751fa9
2 changed files with 80 additions and 83 deletions

View File

@ -1,83 +0,0 @@
Tranalating-------------------geekpi
look : Linux Command To Verify Spellings And Display Lines Beginning With A String
================================================================================
Have you ever felt the need of a command line utility in Linux through which you can verify spellings? A utility that can display lines in file which contain a particular string as a prefix? Well, in this article we will discuss the **look** command in Linux that is capable of doing both these tasks.
### look Command In Linux ###
Here is a snapshot of the description of look command from its man page :
![](http://mylinuxbook.com/wp-content/uploads/2013/12/look-main.png)
### Testing Environment ###
- **OS** Ubuntu 13.04
- **Shell** Bash 4.2.45
- **Application** look 2.20.1-5.1ubuntu8
#### A Brief Tutorial ####
Now lets discuss this command through some practical examples.
Suppose you want to verify the spelling of the word rendezvous. You can do it easily using look command.
Here is an example :
$ look rendez
rendezvous
rendezvous's
rendezvoused
rendezvouses
rendezvousing
So as you can see, I just passed a few initial characters of the word as command line argument and the command produced all the related words. These words are fetched by the look command from the file **/usr/share/dict/words**.
Another scenario could be the one in which it is required to print all the lines beginning with a particular string. For example, if I want to display all the header files that are included in a c file, Id use the look command in the following way :
$ look "#include" efence_test.c
#include <stdio.h>
#include <stdlib.h>
So you can see that it produced all the lines in file efence_test.c that begin with the string “#include” and hence I got to know the header files included in this source file.
By default, all the matching that the look command does is case-sensitive. You can opt for non-case-sensitive matching by using the **-f option**.
Here are some other command line options that the look command provides :
![](http://mylinuxbook.com/wp-content/uploads/2013/12/look-options.png)
For more information on this command, read its [man page][1].
#### Download/Install/Configure ####
Here are some of the important links related to the look command :
- Home Page [*Let me know if you find home page of this utility*]
- Download Link
The look command comes as a part of **util-linux** package which is pre-installed in most of the Linux distributions.
#### Pros ####
- Easily verify spellings from command line
- Comes pre-installed in most of the Linux distributions
#### Cons ####
- Depends on /usr/share/dict/words for spelling verification.
#### Conclusion ####
An excellent command line utility to verify spellings. Saves a lot of time if you want to display lines beginning with a particular string. Try it, youll definitely like it.
--------------------------------------------------------------------------------
via: http://mylinuxbook.com/look-verify-spellings-and-display-lines/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://linux.about.com/library/cmd/blcmdl1_look.htm

View File

@ -0,0 +1,80 @@
look: Linux 下验证拼写并显示以某字符串开头的行的命令
================================================================================
你有没有感到需要一款Linux下的命令行工具它可以验证你的拼写一款可以显示包含特定前缀字符串的行好的本篇中我们会讨论Linux下的 **look**命令,它满足了上面的这些要求。
### Linux下的look命令 ###
下面是来自look命令man页面描述的截图
![](http://mylinuxbook.com/wp-content/uploads/2013/12/look-main.png)
### 测试环境 ###
- **OS** Ubuntu 13.04
- **Shell** Bash 4.2.45
- **Application** look 2.20.1-5.1ubuntu8
#### 简要教程 ####
现在让我们通过一些特定例子来讨论这个命令。
假设你要验证单词'rendezvous'的拼写。你可以轻松地用look命令做到。
这是个例子 :
$ look rendez
rendezvous
rendezvous's
rendezvoused
rendezvouses
rendezvousing
如你所见我只传入了单词的前面几个字符作为命令行参数命令产生了所有的相关单词。这些单词通过look命令从文件 **/usr/share/dict/words**取回。
另外一种情况是需要打印所有包含特定字符串的行。比如如果我想要显示c文件中所有的头文件那么我就用下面的方法
$ look "#include" efence_test.c
#include <stdio.h>
#include <stdlib.h>
如你所见它生成了所有的在文件efence_test.c中以"#include"开始的行,因此我知道了原文件中包含的头文件。
默认上所有look命令的匹配都是大小写敏感的。你可以使用非大小写敏感匹配的选项**-f**。
下面是一些look命令提供了其他一些命令行选项
![](http://mylinuxbook.com/wp-content/uploads/2013/12/look-options.png)
想要获取这个命令的更多信息,阅读这个 [man 页][1].
#### 下载/安装/配置 ####
下面是关于look命令的一些终于链接
- 主页 [*如果你知道这个工具的主页的话让我知道一下*]
- 下载链接
look命令成了**util-linux**包的一部分它在大多数Linux发行版中已经预安装了。
#### 优点 ####
- 非常容易地在命令行验证拼写。
- 在大多数Linux发行版中已经预安装。
#### 缺点 ####
- 依赖于/usr/share/dict/words 来做拼写验证。
#### 总结 ####
一款出色的用来验证拼写的命令行工具。节省了大量时间如果你想要显示以特定字符串为开头的行的话。试一下,你一定会喜欢上它的。
--------------------------------------------------------------------------------
via: http://mylinuxbook.com/look-verify-spellings-and-display-lines/
译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://linux.about.com/library/cmd/blcmdl1_look.htm