LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1275|回复: 10

请问/dev/null有什么作用啊?

[复制链接]
发表于 2004-10-24 14:34:56 | 显示全部楼层 |阅读模式
RT
发表于 2004-10-24 14:47:07 | 显示全部楼层
。吃掉所有给她的东西。。。。。不吐出来。。。

一般就是作用于把无用的结果都导向那里去。
 楼主| 发表于 2004-10-24 15:41:54 | 显示全部楼层
:confused: :confused: 不大明白!
发表于 2004-10-24 15:53:16 | 显示全部楼层
Let's say you have a file called 'messages' which was created like this:

$ ls -lhF | tee messages

Now you don't want to keep the content of the file but you do want to keep the file itself for later use, you may open the file with an editor, select all and delete; another way to do this is to give the following cat command to truncate the file to zero length while preserving the ownership and permissions of the file:

$ cat /dev/null > messages
 楼主| 发表于 2004-10-24 15:59:10 | 显示全部楼层
这样说就明白点的了,那个tee是什么东西?
发表于 2004-10-24 16:02:04 | 显示全部楼层
举个例子来说吧。不知道你在普通用户下执行过find命令没有。
试试这两条命令的输出就知道了:
$find /  -name kernel.h
$find / -name kernel.h  2>/dev/null

2>/dev/null  的意思就是将命令的错误输出通通扔到/dev/null这个无底洞里去
发表于 2004-10-24 16:04:03 | 显示全部楼层
? 我的帖子的时间怎么没对
发表于 2004-10-24 16:07:34 | 显示全部楼层
呵呵,我一直的理解 /dev/null是用来扔东西的,没想到还可以这样用,又学到了,
发表于 2004-10-24 16:16:08 | 显示全部楼层
最初由 Phaedo 发表
那个tee是什么东西?

The tee utility copies standard input to standard ouput and to one or more files you specify on the command line.  Without any options, tee overwrites the output files if they exist, creates the ouput files if they don't exist.  To avoid overwriting existing files you may use the append option:
$  ls -lhF / | tee -a ~/tmp/messages ~/ls-root
 楼主| 发表于 2004-10-24 19:45:14 | 显示全部楼层
谢谢各位的指点!:thank
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表