且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

2>是什么?在Unix命令行上是什么意思?

更新时间:2022-06-15 03:59:30

文件描述符2表示标准错误. (其他特殊文件描述符包括用于标准输入的0和用于标准输出的1).

File descriptor 2 represents standard error. (other special file descriptors include 0 for standard input and 1 for standard output).

2> /dev/null表示将标准错误重定向到/dev/null. /dev/null是一种特殊的设备,它将丢弃所有写入其中的内容.

2> /dev/null means to redirect standard error to /dev/null. /dev/null is a special device that discards everything that is written to it.

将这些代码放在一起,将命令ls $directory_/fallback_* 2> /dev/null的标准输出存储到变量scriptlist中,并丢弃标准错误.

Putting all together, this line of code stores the standard output of command ls $directory_/fallback_* 2> /dev/null into the variable scriptlist, and the standard error is discarded.