日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux /dev/null 21,/dev/null 21 21 与 的意思

發(fā)布時(shí)間:2025/4/5 linux 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux /dev/null 21,/dev/null 21 21 与 的意思 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在linux中,0,1,2,/dev/null,>,>>的意思:

標(biāo)準(zhǔn)輸入stdin的文件描述符為0

標(biāo)準(zhǔn)輸出stdout的文件描述符為1

標(biāo)準(zhǔn)錯(cuò)誤stderr的文件描述符為2

/dev/null為空設(shè)備,相當(dāng)于垃圾桶

輸出重定向符號(hào)為>

>為覆蓋

>>為追加

2>1與2>&1的區(qū)別

2>1把標(biāo)準(zhǔn)錯(cuò)誤stderr重定向到文件1中

2>&1把標(biāo)準(zhǔn)錯(cuò)誤stderr重定向到標(biāo)準(zhǔn)輸出stdout

示例:

test.sh

#! /bin/sh

t

date

標(biāo)準(zhǔn)輸出重定向到log,標(biāo)準(zhǔn)錯(cuò)誤輸出到終端上

$ ls

test.sh

$ ./test.sh > log

./test.sh: 3: ./test.sh: t: not found

$ ls

log test.sh

$ cat log

2017年 06月 28日 星期三 09:30:39 CST

(刪除log文件)標(biāo)準(zhǔn)輸出重定向到log,標(biāo)準(zhǔn)錯(cuò)誤重定向到文件1

$ ls

log test.sh

$ rm log

$ ls

test.sh

$ ./test.sh > log 2>1

$ ls

1 log test.sh

$ cat log

2017年 06月 28日 星期三 09:34:32 CST

$ cat 1

./test.sh: 3: ./test.sh: t: not found

(刪除log文件及1文件)標(biāo)準(zhǔn)輸出重定向到log,標(biāo)準(zhǔn)錯(cuò)誤重定向到標(biāo)準(zhǔn)輸出

$ ls

1 log test.sh

$ rm 1 log

$ ls

test.sh

$ ./test.sh > log 2>&1

$ ls

log test.sh

$ cat log

./test.sh: 3: ./test.sh: t: not found

2017年 06月 28日 星期三 09:36:49 CST

(刪除log文件)標(biāo)準(zhǔn)輸出重定向到空設(shè)備

$ ls

log test.sh

$ rm log

$ ls

test.sh

$ ./test.sh >/dev/null

./test.sh: 3: ./test.sh: t: not found

$ ls

test.sh

標(biāo)準(zhǔn)錯(cuò)誤重定向到空設(shè)備

$ ls

test.sh

$ ./test.sh 2>/dev/null

2017年 06月 29日 星期四 14:23:41 CST

$ ls

test.sh

標(biāo)準(zhǔn)輸出和標(biāo)準(zhǔn)錯(cuò)誤全定向到空設(shè)備

$ ls

test.sh

$ ./test.sh >/dev/null 2>&1

$ ls

test.sh

總結(jié)

以上是生活随笔為你收集整理的linux /dev/null 21,/dev/null 21 21 与 的意思的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。