怎么让bash不报任何错误呢?[已解决]

sh/bash/dash/ksh/zsh等Shell脚本
回复
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

怎么让bash不报任何错误呢?[已解决]

#1

帖子 sanz » 2009-04-16 16:38

怎么让bash不显示任何错误呢?存储为一个变量中。是不是什么管道定向啊?不懂。
上次由 sanz 在 2009-04-17 5:56,总共编辑 1 次。
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
头像
hellojinjie
帖子: 1150
注册时间: 2007-09-14 21:03
来自: 浙江

Re: 怎么让bash不报任何错误呢?

#2

帖子 hellojinjie » 2009-04-16 17:17

2 > /dev/null
Say hello to everyday!
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

Re: 怎么让bash不报任何错误呢?

#3

帖子 sanz » 2009-04-16 17:27

还是有红色的报错啊!不是BASH本身的报错,是程序的报错。

> /dev/null我知道的,那个前面的"2"是什么意思啊?
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
pope123
帖子: 34
注册时间: 2008-09-21 1:01

Re: 怎么让bash不报任何错误呢?

#4

帖子 pope123 » 2009-04-16 18:01

同问
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

Re: 怎么让bash不报任何错误呢?

#5

帖子 sanz » 2009-04-17 5:56

虽然man中没有-b的选项,但是居然真有用。看样子这个参数是通用的
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
头像
HuntXu
帖子: 5776
注册时间: 2007-09-29 3:09

Re: 怎么让bash不报任何错误呢?[已解决]

#6

帖子 HuntXu » 2009-04-17 7:41

2是标准错误信息...当然有用...
:em26
However, there is much more to redirection than this simple example reveals. You’ll learn more about the
standard file descriptors in Chapter 3, but for now all you need to know is that file descriptor 0 is the standard
input to a program, file descriptor 1 is the standard output, and file descriptor 2 is the standard error
output. You can redirect each of these independently. In fact, you can also redirect other file descriptors, but
it’s unusual to want to redirect any other than the standard ones: 0, 1, and 2.
HUNT Unfortunately No Talent...
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

Re: 怎么让bash不报任何错误呢?[已解决]

#7

帖子 sanz » 2009-04-17 10:51

怎么用啊?
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
头像
lerosua
论坛版主
帖子: 8455
注册时间: 2007-11-29 9:41
联系:

Re: 怎么让bash不报任何错误呢?[已解决]

#8

帖子 lerosua » 2009-04-17 12:29

不报错的话,有错也查不出,不好吧,呵呵
回复