/usr/share/doc/HOWTO/ja-html/Bash-Prog-Intro-HOWTO-3.html is in doc-linux-ja-html 2006.05.25-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>BASH Programming - Introduction HOW-TO: ¥ê¥À¥¤¥ì¥¯¥È¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ(redirection)</TITLE>
<LINK HREF="Bash-Prog-Intro-HOWTO-4.html" REL=next>
<LINK HREF="Bash-Prog-Intro-HOWTO-2.html" REL=previous>
<LINK HREF="Bash-Prog-Intro-HOWTO.html#toc3" REL=contents>
</HEAD>
<BODY>
<A HREF="Bash-Prog-Intro-HOWTO-4.html">¼¡¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO-2.html">Á°¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO.html#toc3">Ìܼ¡¤Ø</A>
<HR>
<H2><A NAME="s3">3. ¥ê¥À¥¤¥ì¥¯¥È¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ(redirection)</A></H2>
<H2><A NAME="ss3.1">3.1 ÍýÏÀ¤È´Êñ¤Ê¥ê¥Õ¥¡¥ì¥ó¥¹</A>
</H2>
<P><CODE>bash</CODE> ¤Ë¤Ï¡¢¥Õ¥¡¥¤¥ëµ½Ò»Ò(file descriptor)¤È¤·¤Æ¡¢É¸½àÆþÎÏ
(<CODE>stdin</CODE>)¡¢É¸½à½ÐÎÏ(<CODE>stdout</CODE>)¡¢¤½¤·¤Æɸ½à¥¨¥é¡¼(<CODE>stderr</CODE>)
¤Î 3 ¤Ä¤¬¤¢¤ê¤Þ¤¹¡£
( std ¤Ï standard ¤Î°ÕÌ£¤Ç¤¹¡£)
<P>
<P>´ðËÜŪ¤Ë°Ê²¼¤Î¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
<OL>
<LI><CODE>stdout</CODE> ¤ò <CODE>file</CODE> ¤Ë¥ê¥À¥¤¥ì¥¯¥È</LI>
<LI><CODE>stderr</CODE> ¤ò <CODE>file</CODE> ¤Ë¥ê¥À¥¤¥ì¥¯¥È</LI>
<LI><CODE>stdout</CODE> ¤ò <CODE>stderr</CODE> ¤Ë¥ê¥À¥¤¥ì¥¯¥È</LI>
<LI><CODE>stderr</CODE> ¤ò <CODE>stdout</CODE> ¤Ë¥ê¥À¥¤¥ì¥¯¥È</LI>
<LI><CODE>stderr</CODE> ¤È <CODE>stdout</CODE> ¤ò <CODE>file</CODE> ¤Ë¥ê¥À¥¤¥ì¥¯¥È</LI>
<LI><CODE>stderr</CODE> ¤È <CODE>stdout</CODE> ¤ò <CODE>stdout</CODE> ¤Ë¥ê¥À¥¤¥ì¥¯¥È</LI>
<LI><CODE>stderr</CODE> ¤È <CODE>stdout</CODE> ¤ò <CODE>stderr</CODE> ¤Ë¥ê¥À¥¤¥ì¥¯¥È</LI>
</OL>
<P>(¥ê¥À¥¤¥ì¥¯¥È¹½Ê¸¤Ç¤Ï)¿ô»ú¤Î <CODE>1</CODE> ¤Ï <CODE>stdout</CODE> ¤òɽ¤·¡¢
<CODE>2</CODE> ¤Ï <CODE>stderr</CODE> ¤òɽ¤·¤Þ¤¹¡£
<P>
<P>*¾åµ¤Î¹àÌܤ½¤ì¤¾¤ì¤Ë¤Ä¤¤¤Æ¤Î´Êñ¤Ê¥á¥â* <CODE>less</CODE> ¥³¥Þ¥ó¥É¤ò»È¤¦¤È¡¢
<CODE>stdout</CODE> (¤³¤ì¤Ï¥Ð¥Ã¥Õ¥¡¤Ë»Ä¤ê¤Þ¤¹)¤È <CODE>stderr</CODE> (¥¹¥¯¥ê¡¼¥ó¤Ë¤Ï
ɽ¼¨¤µ¤ì¤Þ¤¹¤¬¡¢¤½¤Î¥Ð¥Ã¥Õ¥¡¤ò¸«¤è¤¦¤È¤¹¤ë¤È¾Ãµî¤µ¤ì¤Æ¤·¤Þ¤¤¤Þ¤¹)¤ÎξÊý¤ò¸«¤ë
¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
<P>
<H2><A NAME="ss3.2">3.2 ¥µ¥ó¥×¥ë: stdout ¤ò file ¤Ø </A>
</H2>
<P>¼¡¤Î¾ì¹ç¡¢¥×¥í¥°¥é¥à¤Î½ÐÎϤ¬¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤Þ¤ì¤Þ¤¹¡£
<P>
<BLOCKQUOTE><CODE>
<PRE>
$ ls -l > ls-l.txt
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>¾åµ¤Ç¤Ï <CODE>ls-l.txt</CODE> ¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£¤½¤·¤Æ¡¢'<CODE>ls -l</CODE>' ¤È¤¤¤¦¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤¿¾ì¹ç¤Ë¥¹¥¯¥ê¡¼¥ó¤Ëɽ¼¨¤µ¤ì¤ë
ÆâÍƤ¬¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤ËÊݸ¤µ¤ì¤Þ¤¹¡£
<P>
<H2><A NAME="ss3.3">3.3 ¥µ¥ó¥×¥ë: stderr ¤ò file ¤Ø </A>
</H2>
<P>¼¡¤Î¾ì¹ç¡¢¥×¥í¥°¥é¥à¤Î <CODE>stderr</CODE> ¤Î½ÐÎϤ¬¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤Þ¤ì¤Þ¤¹¡£
<P>
<BLOCKQUOTE><CODE>
<PRE>
$ grep da * 2> grep-errors.txt
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>¾åµ¤Ç¤Ï¡¢<CODE>grep-errors.txt</CODE> ¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£¤½¤·¤Æ¡¢
¤½¤Î¥Õ¥¡¥¤¥ë¤Ë¤Ï¡¢'<CODE>grep da *</CODE>' ¤Î½ÐÎϤΤ¦¤Á¡¢ÆɼԤ¬¸«¤è¤¦¤È¤·¤Æ¤¤¤ë
¤Ï¤º¤Î <CODE>stderr</CODE> ¤ÎÉôʬ¤¬½ñ¤¹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£
<P>
<H2><A NAME="ss3.4">3.4 ¥µ¥ó¥×¥ë: stdout ¤ò stderr ¤Ø</A>
</H2>
<P>¼¡¤Î¾ì¹ç¡¢¥×¥í¥°¥é¥à¤Î <CODE>stderr</CODE> ½ÐÎϤ¬¡¢<CODE>stdout</CODE> ¤ÈƱ°ì¤Î
¥Õ¥¡¥¤¥ëµ½Ò»Ò¤Ë½ñ¤¹þ¤Þ¤ì¤Þ¤¹¡£
<P>
<BLOCKQUOTE><CODE>
<PRE>
$ grep da * 1>&2
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>¾åµ¤Ç¤Ï¡¢¥³¥Þ¥ó¥É¤Î <CODE>stdout</CODE> ¤ÎÉôʬ¤¬ <CODE>stderr</CODE> ¤ËÁ÷¤é¤ì¤Þ¤¹¡£
Ê̤Τä¤êÊý¤¬¤¢¤ë¤³¤È¤ËÆɼԤϵ¤ÉÕ¤¤¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
<P>
<H2><A NAME="ss3.5">3.5 ¥µ¥ó¥×¥ë: stderr ¤«¤é stdout ¤Ø</A>
</H2>
<P>¼¡¤Î¾ì¹ç¡¢¥×¥í¥°¥é¥à¤Î <CODE>stderr</CODE> ½ÐÎϤ¬¡¢<CODE>stdout</CODE> ¤ÈƱ°ì¤Î¥Õ¥¡¥¤¥ë
µ½Ò»Ò¤Ë½ñ¤¹þ¤Þ¤ì¤Þ¤¹¡£
<P>
<BLOCKQUOTE><CODE>
<PRE>
$ grep * 2>&1
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>¾åµ¤Ç¤Ï¡¢¥³¥Þ¥ó¥É¤Î <CODE>stderr</CODE> ¤ÎÉôʬ¤¬ <CODE>stdout</CODE> ¤ËÁ÷¤é¤ì¤Þ¤¹¡£
¤·¤¿¤¬¤Ã¤Æ¡¢¤â¤·¥Ñ¥¤¥×¤ò»È¤Ã¤Æ <CODE>less</CODE> ¤Ëή¤»¤Ð¡¢Ä̾ï¤Ê¤é <CODE>stderr</CODE> ¤Ë½ñ¤¹þ¤Þ¤ì¤Æ¾Ã¤¨¤Æ¤·¤Þ¤¦¤Ï¤º¤Î½ÐÎϹԤ¬¡¢ <CODE>stdout</CODE> ¤ËÁ÷¤é¤ì¤¿¤³¤È
¤ÇÊÝ»ý¤µ¤ì¤Æ¤¤¤ë¤Î¤ò³Îǧ¤Ç¤¤Þ¤¹¡£
<P>
<H2><A NAME="ss3.6">3.6 ¥µ¥ó¥×¥ë: stderr ¤È stdout ¤«¤é file ¤Ø</A>
</H2>
<P>¼¡¤Î¾ì¹ç¡¢¥×¥í¥°¥é¥à¤ÎÁ´¤Æ¤Î½ÐÎϤ¬¥Õ¥¡¥¤¥ë¤ËÆþ¤ì¤é¤ì¤Þ¤¹¡£¤³¤ì¤Ï¡¢´°Á´¤Ë
Ìۤäƥ³¥Þ¥ó¥É¤ò¼Â¹Ô¤µ¤»¤¿¤¤¤è¤¦¤Ê <CODE>cron</CODE> ¤Î¼Â¹Ô¹àÌܤò½ñ¤¯¾ì¹ç¤ËŬ¤·¤Æ
¤¤¤Þ¤¹¡£
<P>
<BLOCKQUOTE><CODE>
<PRE>
$ rm -f $(find / -name core) &> /dev/null
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P><CODE>cron</CODE> ¥×¥í¥°¥é¥à¤Î¼Â¹Ô¹àÌܤò»×¤¤É⤫¤Ù¤Æ¤Û¤·¤¤¤Î¤Ç¤¹¤¬¡¢¾åµ¤Ï¡¢
¤¢¤é¤æ¤ë¥Ç¥£¥ì¥¯¥È¥ê¤«¤é "<CODE>core</CODE>" ¤È¸Æ¤Ð¤ì¤ë¥Õ¥¡¥¤¥ë¤ò¤¹¤Ù¤Æºï½ü¤¹¤ë
¤â¤Î¤Ç¤¹¡£
¥³¥Þ¥ó¥É¤Î½ÐÎϤò¸«¤¨¤Ê¤¯¤·¤Æ¤·¤Þ¤¦¾ì¹ç¤Ï¡¢¤½¤Î¥³¥Þ¥ó¥É¤¬¤É¤¦¤¤¤¦½èÍý¤ò¤¹
¤ë¤Î¤«½¼Ê¬Ç§¼±¤·¤Æ¤ª¤«¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó¡£
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<HR>
<A HREF="Bash-Prog-Intro-HOWTO-4.html">¼¡¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO-2.html">Á°¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO.html#toc3">Ìܼ¡¤Ø</A>
</BODY>
</HTML>
|