/usr/share/doc/HOWTO/ja-html/Bash-Prog-Intro-HOWTO-6.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 | <!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: ¾ò·ïÀ©¸æ(conditionals)</TITLE>
<LINK HREF="Bash-Prog-Intro-HOWTO-7.html" REL=next>
<LINK HREF="Bash-Prog-Intro-HOWTO-5.html" REL=previous>
<LINK HREF="Bash-Prog-Intro-HOWTO.html#toc6" REL=contents>
</HEAD>
<BODY>
<A HREF="Bash-Prog-Intro-HOWTO-7.html">¼¡¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO-5.html">Á°¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO.html#toc6">Ìܼ¡¤Ø</A>
<HR>
<H2><A NAME="s6">6. ¾ò·ïÀ©¸æ(conditionals)</A></H2>
<P>¾ò·ïÀ©¸æ¤ò»È¤¨¤Ð¡¢¤¢¤ëÌ¿Îá¤ò¼Â¹Ô¤ò¤¹¤Ù¤¤«¤É¤¦¤«¤Î·èÄ꤬¤Ç¤¤Þ¤¹¡£
¤½¤·¤Æ¡¢¤³¤Î·èÄê¤Ï¡¢¼°¤Îɾ²Á¤Ë¤è¤ê¤Ê¤µ¤ì¤Þ¤¹¡£
<P>
<H2><A NAME="ss6.1">6.1 ¥»¥ª¥ê¡¼</A>
</H2>
<P>¾ò·ïÀ©¸æ¤Ë¤Ï¡¢Â¿¤¯¤Î·Á¼°¤¬¤¢¤ê¤Þ¤¹¡£ºÇ¤â´ðËÜŪ¤Ê·Á¼°¤Ï¡¢¡Ö<CODE>if</CODE> ¾ò·ï¼°
<CODE>then</CODE> ¼Â¹Ôʸ¡× ¤Ç¤¢¤ê¡¢¤³¤Î¼Â¹Ôʸ¤Ï
¾ò·ï¼°¤Îɾ²Á¤¬¿¿¤Ç¤¢¤ë¤È¤¤À¤±¼Â¹Ô¤µ¤ì¤Þ¤¹¡£" <CODE>2 < 1</CODE>
" ¤È¤¤¤¦¤Î¤Ïµ¶¤Èɾ²Á¤µ¤ì¤ë¾ò·ï¼°¤Ç¤¢¤ê¡¢" <CODE>2 > 1</CODE>
" ¤È¤¤¤¦¤Î¤Ï¿¿¤Èɾ²Á¤µ¤ì¤ë¾ò·ï¼°¤Ç¤¹¡£
<P>
<P>¤Þ¤¿¡¢¾ò·ïÀ©¸æ¤Ï¡¢¡Ö<CODE>if</CODE> ¾ò·ï¼° <CODE>then</CODE> ¼Â¹Ôʸ<CODE>1 </CODE>
<CODE>else</CODE> ¼Â¹Ôʸ<CODE>2 </CODE>¡×¤È¤¤¤¦·Á¼°¤â¤È¤ê¤Þ
¤¹¡£¤³¤³¤Ç¤Ï¡¢¾ò·ï¼°¤¬
¿¿¤Î¤È¤¼Â¹Ôʸ <CODE>1</CODE> ¤¬¼Â¹Ô¤µ¤ì¡¢¤½¤ì°Ê³°¤Î¤È¤¤Ï¼Â¹Ôʸ <CODE>2</CODE> ¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
<P>
<P>¾ò·ïÀ©¸æ¤Ë¤Ï¤µ¤é¤ËÊ̤ηÁ¼°¤â¤¢¤ê¤Þ¤¹¡£¡Ö<CODE>if</CODE> ¾ò·ï¼°<CODE>1 </CODE>
<CODE>then</CODE> ¼Â¹Ôʸ<CODE>1 </CODE> <CODE>else if</CODE> ¾ò·ï¼°<CODE>2 </CODE> ¼Â¹Ôʸ
<CODE>2 </CODE> <CODE>else</CODE> ¼Â¹Ôʸ<CODE>3 </CODE>¡× ¤Ç¤¹¡£¤³¤Î·Á¼°¤Ç¤Ï¡¢
"<CODE>else if</CODE> ¾ò·ï¼°<CODE>2 </CODE> <CODE>then</CODE> ¼Â¹Ôʸ<CODE>2 </CODE>
" ¤È¤¤¤¦¤Î¤¬²Ã¤ï¤Ã¤¿¤À¤±¤Ç¤¹¤¬¡¢¤³¤ì¤Ï¤â¤·¾ò·ï¼°<CODE>2 </CODE>¤Îɾ²Á¤¬¿¿
¤Ê¤é¤Ð¼Â¹Ôʸ<CODE>2 </CODE> ¤ò¼Â¹Ô¤¹¤ë¤â¤Î¤Ç¤¹¡£
¤½¤Î¾¤ÎÉôʬ¤Ë¤Ä¤¤¤Æ¤Ï¡¢ÆɼԤÎÁÛÁüÄ̤ê¤Ç¤¹¡£(¤³¤ì¤Þ¤Ç¤Î·Á¼°¤ò¤´Í÷¤¯¤À¤µ¤¤)
<P>
<P>¹½Ê¸¤Ë´Ø¤·¤Æ¤Ç¤¹¤¬¡¢
<CODE>bash</CODE> ¤Ç <CODE>if</CODE> À©¸æ¹½Â¤¤ò»È¤¦¤È¤¤Î´ðËܤϰʲ¼¤Î¤è¤¦¤Ê¤â¤Î¤Ç¤¹¡£
<PRE>
if [¾ò·ï¼°]
then
(if ¤Î¾ò·ï¤¬¿¿¤À¤Ã¤¿¤È¤¤Î)¼Â¹Ô¥³¡¼¥É
fi
</PRE>
<P>
<H2><A NAME="ss6.2">6.2 ¥µ¥ó¥×¥ë: if .. then ¤Ë¤è¤ë´ðËÜŪ¤Ê¾ò·ïÀ©¸æ¤ÎÎã</A>
</H2>
<P>
<BLOCKQUOTE><CODE>
<PRE>
#!/bin/bash
if [ "foo" = "foo" ]; then
echo expression evaluated as true
fi
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>¥Ö¥ì¡¼¥¹ [ ] Æâ¤Î¾ò·ï¼°¤¬¿¿¤Ç¤¢¤Ã¤¿¾ì¹ç¡¢"<CODE>then</CODE>" ¤È¤¤¤¦
ʸ»ú¤Î¸å¤Ë¡¢¼Â¹Ô¤µ¤ì¤ë¥³¡¼¥É¤¬½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡£¤½¤·¤Æ¤½¤Î¸å¤Ë¡¢¾ò·ïÀ©¸æ¤Ë´ð¤Å
¤¤¤Æ¼Â¹Ô¤µ¤ì¤ë¥³¡¼¥É¤Î½ªÎ»¤ò»Ø¼¨¤¹¤ë "<CODE>fi</CODE>" ¤¬ÃÖ¤«¤ì¤Æ
¤¤¤Þ¤¹¡£
<P>
<H2><A NAME="ss6.3">6.3 ¥µ¥ó¥×¥ë: "if .. then ... else" ¤ò»È¤Ã¤¿´ðËÜŪ¤Ê¾ò·ïÀ©¸æ¤ÎÎã</A>
</H2>
<P>
<BLOCKQUOTE><CODE>
<PRE>
#!/bin/bash
if [ "foo" = "foo" ]; then
echo expression evaluated as true
else
echo expression evaluated as false
fi
</PRE>
</CODE></BLOCKQUOTE>
<H2><A NAME="ss6.4">6.4 ¥µ¥ó¥×¥ë: ÊÑ¿ô¤òȼ¤Ã¤¿¾ò·ïÀ©¸æ</A>
</H2>
<P>
<BLOCKQUOTE><CODE>
<PRE>
#!/bin/bash
T1="foo"
T2="bar"
if [ "$T1" = "$T2" ]; then
echo expression evaluated as true
else
echo expression evaluated as false
fi
</PRE>
</CODE></BLOCKQUOTE>
<HR>
<A HREF="Bash-Prog-Intro-HOWTO-7.html">¼¡¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO-5.html">Á°¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO.html#toc6">Ìܼ¡¤Ø</A>
</BODY>
</HTML>
|