Tag: command


[翻译]通过Unix命令行成为一个优秀的写作者

July 16th, 2009 — 10:31am

Become a Better Writer from Unix Command Line
原文链接

在本文中我们介绍如何利用Unix/Linux命令行来纠正单词的拼写,确认单词的解释,确认单词的反义词。

1.根据开始的某几个字符串查找单词
命令 look

$ look typogr
typograph
typographer
typographers
typographia
typographic
typographical
typographically
typographies
typographist
typography

输入“typogr”,会显示以这些字符开头的单词

译注:首次使用可能需要安装字典,Ubuntu用户可以通过新德利安装wamerican, wbritish

2.查找单词的正确解释
命令 mean

利用mean命令可以显示单词的正确解释

$ mean philosophy
Overview of noun philosophy

The noun philosophy has 3 senses (first 3 from tagged texts)

1. (12) doctrine, philosophy, philosophical system, school of thought, ism — (a belief (or system of beliefs) accepted as authoritative by some group or school)
2. (8) philosophy — (the rational investigation of questions about existence and knowledge and ethics)
3. (1) philosophy — (any personal belief about how to live or how to deal with a situation; "self-indulgence was his only philosophy"; "my father’s philosophy of child-rearing was to let mother do it")

Synonyms/Hypernyms (Ordered by Estimated Frequency) of noun philosophy

3 senses of philosophy

Sense 1
doctrine, philosophy, philosophical system, school of thought, ism

=> belief

Sense 2
philosophy

=> humanistic discipline, humanities, liberal arts, arts

Sense 3
philosophy

=> belief

3.查找单词的正确解释
命令 dict

dict命令显示dict.org网站中给出单词的解释

$ dict philosophy

1. Literally, the love of, inducing the search after, wisdom;

in actual usage, the knowledge of phenomena as explained

by, and resolved into, causes and reasons, powers and

laws.

[1913 Webster]

译注:Ubuntu用户可以通过新德利安装

4.在Vi/Vim编辑器中查询单词的解释
在编辑器配置文件中添加如下快捷脚本
map <F3> :exe ":!dict ".expand("<cword>")
想要查找单词的解释只需按下F3
如果你不怎么熟悉vim中的map指令,可以阅读我们的Vim小贴示Vi/Vim Editor Macro, Mark and Map Examples.

5.查找反义词 命令 wn
命令wn可以利用参数查找不同词性的反义词

$ wn search-str -antsa

*
WordNet command
* search-str: 需要查询的单词
* -antsa: 反义词参数

(n | v | a | r) – 名词反义词 | 动词 | 形容词 | 副词

译注:Ubuntu用户可以通过新德利安装

6.如果都不行,试试谷歌
define: 单词

Comment » | 翻译

[翻译]15个Unix LS命令实例

July 14th, 2009 — 7:48pm

Unix LS Command: 15 Practical Examples
原文链接

无论是Unix用户还是Unix系统管理员都离不开LS命令,不管你是一天内使用10次还是100次,掌握LS命令对你在命令行下的旅程绝对是有意义的。

在这篇文章中,我们展示强大的LS命令15个实例。

1.显示最后一次编辑过的文件

ls -t

2.每行显示一个文件
ls -1

3.显示文件/目录的详细信息
ls-l

4.显示更易理解的文件大小样式
ls -lh

$ ls -l
-rw-r—– 1 ramesh team-dev 9275204 Jun 12 15:27 arch-linux.txt.gz*

$ ls -lh
-rw-r—– 1 ramesh team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz

5.显示目录的信息 ls -ld
使用“ls -l”命令将得到目录所含内容的细节,但如果想显示文件夹的细节你可以使用-d选项,如下例子,使用 ls -l /etc 将显示所有在etc文件夹下的文档和目录。但是,如果你想要显示/etc/目录的信息,你就要使用 -ld命令
$ ls -l /etc
total 3344
-rw-r–r–

1 root root

15276 Oct
5
2004 a2ps.cfg
-rw-r–r–

1 root root

2562 Oct
5
2004 a2ps-site.cfg
drwxr-xr-x

4 root root

4096 Feb
2
2007 acpi
-rw-r–r–

1 root root

48 Feb
8
2008 adjtime
drwxr-xr-x

4 root root

4096 Feb
2
2007 alchemist

$ ls -ld /etc
drwxr-xr-x 21 root root 4096 Jun 15 07:02 /etc

6.根据文件最后使用时间进行排序 ls -lt
$ ls -lt
total 76
drwxrwxrwt
14 root root
4096 Jun 22 07:36 tmp
drwxr-xr-x 121 root root
4096 Jun 22 07:05 etc
drwxr-xr-x
13 root root 13780 Jun 22 07:04 dev
drwxr-xr-x
13 root root
4096 Jun 20 23:12 root
drwxr-xr-x
12 root root
4096 Jun 18 08:31 home
drwxr-xr-x

2 root root
4096 May 17 21:21 sbin
lrwxrwxrwx

1 root root

11 May 17 20:29 cdrom -> media/cdrom
drwx——

2 root root 16384 May 17 20:29 lost+found
drwxr-xr-x
15 root root
4096 Jul
2
2008 var

7.根据文件最后使用时间进行排序(逆序) ls -lt
$ ls -ltr

total 76
drwxr-xr-x
15 root root
4096 Jul
2
2008 var
drwx——

2 root root 16384 May 17 20:29 lost+found
lrwxrwxrwx

1 root root

11 May 17 20:29 cdrom -> media/cdrom
drwxr-xr-x

2 root root
4096 May 17 21:21 sbin
drwxr-xr-x
12 root root
4096 Jun 18 08:31 home
drwxr-xr-x
13 root root
4096 Jun 20 23:12 root
drwxr-xr-x
13 root root 13780 Jun 22 07:04 dev
drwxr-xr-x 121 root root
4096 Jun 22 07:05 etc
drwxrwxrwt
14 root root
4096 Jun 22 07:36 tmp

8.显示隐藏文件 ls-a 或 ls -A
在Unix中隐藏文件是以‘.’开头的
$ ls -a
[rnatarajan@asp-dev ~]$ ls -a
.

Debian-Info.txt
..

CentOS-Info.txt
.bash_history

Fedora-Info.txt
.bash_logout

.lftp
.bash_profile

libiconv-1.11.tar.tar
.bashrc

libssh2-0.12-1.2.el4.rf.i386.rpm
如果不想显示‘.’当前目录和’..’父目录可以使用选项 -A
$ ls -A
Debian-Info.txt

Fedora-Info.txt
CentOS-Info.txt

Red-Hat-Info.txt
.bash_history

SUSE-Info.txt
.bash_logout

.lftp
.bash_profile

libiconv-1.11.tar.tar
.bashrc

libssh2-0.12-1.2.el4.rf.i386.rpm
[Note: . and .. are not displayed here]

9.递归显示目录 ls -R
$ ls
/etc/sysconfig/networking
devices
profiles

$ ls
-R /etc/sysconfig/networking
/etc/sysconfig/networking:
devices
profiles

/etc/sysconfig/networking/devices:

/etc/sysconfig/networking/profiles:
default

/etc/sysconfig/networking/profiles/default:

如用此命令显示/ ,将不会显示隐藏文件

10.显示文件索引号 ls -i
$ ls -i /etc/xinetd.d/
279694 chargen

279724 cups-lpd
279697 daytime-udp
279695 chargen-udp
279696 daytime

279698 echo

11.隐藏控制字符 ls -q

12.显示文件的UID和GID ls -n
$ ls -l ~/.bash_profile
-rw-r–r–
1 ramesh ramesh 909 Feb
8 11:48 /home/ramesh/.bash_profile
$ ls -n ~/.bash_profile
-rw-r–r–
1 511 511 909 Feb
8 11:48 /home/ramesh/.bash_profile

13.利用特殊字符直观显示文档 ls -F
$ ls -F
Desktop/
Documents/
Ubuntu-App@
firstfile
Music/
Public/
Templates/

*
/ – 目录.

* 无显示 – 正常文件.

* @ – 链接文件.

* * – 可执行文件

14.色彩分辨文件 ls –color=auto
目录显示蓝色,软链接显示绿色,普通文件显示默认颜色

15.有用的ls别名
*
直观显示文件大小.

alias ll="ls -lh"

* 特殊字符直观显示文档.

alias lv="ls -F"

* 特殊字符直观显示文档并进行色彩分辨.

alias ls="ls -F –color=auto"

Comment » | 翻译

Back to top