5)nl

nl命令其它和cat命令很像,只不过它会打上行号。如下所示:

[hchen@RHELSVR5 include]# nl stdio.h | head -n 10
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004,2005,2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,

6)mkfifo

熟悉Unix的人都应该知道这个是一个创建有名管道的系统调用或命令。平时,我们在命令行上使用竖线“|”把命令串起来是使用无命管道。而我们使用mkfifo则使用的是有名管道。下面是示例:

下面是创建一个有名管道:

[hchen@RHELSVR5 ~]# mkfifo /tmp/hchenpipe
[hchen@RHELSVR5 ~]# ls -l /tmp
prw-rw-r-- 1 hchen hchen 0 05-10 18:58 hchenpipe

然后,我们在一个shell中运行如下命令,这个命令不会返回,除非有人从这个有名管道中把信息读走。

[hchen@RHELSVR5 ~]# ls -al > /tmp/hchenpipe

我们在另一个命令窗口中读取这个管道中的信息:其会导致上一个命令返回)

01 [hchen@RHELSVR5 ~]# head /tmp/hchenpipe
02 drwx------ 8 hchen hchen 4096 05-10 18:27 .
03 drwxr-xr-x 7 root root 4096 03-05 00:06 ..
04 drwxr-xr-x 3 hchen hchen 4096 03-01 18:13 backup
05 -rw------- 1 hchen hchen 721 05-05 22:12 .bash_history
06 -rw-r--r-- 1 hchen hchen 24 02-28 22:20 .bash_logout
07 -rw-r--r-- 1 hchen hchen 176 02-28 22:20 .bash_profile
08 -rw-r--r-- 1 hchen hchen 124 02-28 22:20 .bashrc
09 -rw-r--r-- 1 root root 14002 03-07 00:29 index.htm
10 -rw-r--r-- 1 hchen hchen 31465 03-01 23:48 index.php


相关内容