[Linux] '/dev/null 2<&1'ÀÇ ÀǹÌ

   Á¶È¸ 13101   Ãßõ 0    

Summary1316;1116;Ȣ16;1648;않lj16; 파1068; 'nofile.txt'1012; cat 명/16112;/196; 1648;122116;면 1068;0152;1201;1004;/196; 아래와 같1008; 결과를 Ǻ19;lj16;다. 1593;, 실행결과와 에러를 표1456; 출/141;1109;치(/dev/tty)/196; 출/141;합니다.

[opradm@hvdev-tst-svr01 ~]$ cat nofile.txt
cat: nofile.txt: No such file or directory



'>'lj16; 표1456;출/141;1032; FD를 변ᅆ1;

[opradm@hvdev-tst-svr01 ~]$ cat nofile.txt > /dev/null
cat: nofile.txt: No such file or directory
[opradm@hvdev-tst-svr01 ~]$

'>'lj16; '1>'와 ᇼ1;1068;Ȣ16;다.




'2>&1 > /dev/null'과 '> /dev/null 2>&1'1032; 차1060;1216;

[opradm@hvdev-tst-svr01 ~]$ cat nofile.txt 2>&1 > /dev/null
cat: nofile.txt: No such file or directory
[opradm@hvdev-tst-svr01 ~]$ cat nofile.txt > /dev/null 2>&1
[opradm@hvdev-tst-svr01 ~]$


The&means file descriptor1. So2>&1redirects standard error to whatever standard output currently points at, while2>1redirects standard error into a file called1.

Also, the redirects happen in order. So if you say2>&1 >/dev/null, it redirects standard error to point at what standard output currently points at (which is probably a noop), then redirects stdout to /dev/null.

'> /dev/null 2>&1'1008; '&> /dev/null'와 ᇼ1;1068;Ȣ16;다.


References

https://codingdog.tistory.com/entry/%EB%A6%AC%EB%88%85%EC%8A%A4-%EB%AA%85%EB%A0%B9%EC%96%B4-devnull-21-%EC%9D%98-%EC%9D%98%EB%AF%B8%EB%A5%BC-%EC%95%8C%EC%95%84%EB%B4%85%EC%8B%9C%EB%8B%A4

https://linuxhint.com/redirect-stdout-and-stderr-to-file/



Á¦¸ñPage 22/26
2022-01   6321   ¹Ú¹®Çü
2022-03   9217   ¹ÌÄ£°¨ÀÚ
2022-07   22792   µö·¯´×¼­¹ö
2022-12   43627   ÃѾËź»ç³ªÀÌ
2023-04   38609   µö·¯´×¼­¹ö
2023-09   53462   µö·¯´×¼­¹ö
01-25   15504   µö·¯´×¼­¹ö
2012-02   33404   ÀÌÁöÆ÷Åä
2019-07   13770   »ßµ¹À̽½ÇÄÀÌ
2020-09   23570   PCMaster
2021-01   7985   µö·¯´×¼­¹ö
2021-05   7448   shipse
2021-09   9961   µö·¯´×¼­¹ö
2022-04   9412   µö·¯´×¼­¹ö
2023-01   50566   µö·¯´×¼­¹ö
2012-02   41795   MikroTikÀÌÁø
2015-02   37581   ȲÁø¿ì
2016-11   38489   stone92±è°æ¹Î
2017-07   46182   ¼¼¹ú½­
2018-09   20842   ±èȲÁß