/usr/share/doc/HOWTO/ja-html/Bash-Prog-Intro-HOWTO-7.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 | <!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: for, while, until ¤Ë¤è¤ë¥ë¡¼¥×</TITLE>
<LINK HREF="Bash-Prog-Intro-HOWTO-8.html" REL=next>
<LINK HREF="Bash-Prog-Intro-HOWTO-6.html" REL=previous>
<LINK HREF="Bash-Prog-Intro-HOWTO.html#toc7" REL=contents>
</HEAD>
<BODY>
<A HREF="Bash-Prog-Intro-HOWTO-8.html">¼¡¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO-6.html">Á°¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO.html#toc7">Ìܼ¡¤Ø</A>
<HR>
<H2><A NAME="s7">7. for, while, until ¤Ë¤è¤ë¥ë¡¼¥×</A> </H2>
<P>¤³¤Î¾Ï¤Ç¤Ï¡¢<CODE>for</CODE>, <CODE>while</CODE>, ¤½¤·¤Æ <CODE>util</CODE> ¤Ë¤è¤ë¥ë¡¼
¥×¤Ë¤Ä¤¤¤Æ½Ò¤Ù¤Þ¤¹¡£
<CODE>bash</CODE> ¤Î <CODE>for</CODE> ¤Ï¡¢Â¾¤Î¸À¸ì¤Ç¤Î»È¤¤Êý¤È¼ã´³°Û¤Ê¤ê¤Þ¤¹¡£´ðËÜŪ¤Ë
¤Ï¡¢¤¢¤ëʸ»úÎóÆâ¤Îñ¸ì¤ò¤¢¤¿¤Þ¤«¤é½ç¤ËÈ¿Éü½èÍý¤¹¤ë¤â¤Î¤Ç¤¹¡£
<P>
<P><CODE>while</CODE> ¤Ï¡¢À©¸æ¼°¤¬¿¿¤Î´Ö¤Ï¥³¡¼¥É¤ò¼Â¹Ô¤·¤Æ¤¤¤Æ¡¢µ¶¤Ë¤Ê¤Ã¤¿¤È¤
(¤¢¤ë¤¤¤Ï¼Â¹Ô¥³¡¼¥ÉÆâ¤Ë <CODE>break</CODE> ¤¬ÌÀ¼¨¤µ¤ì¤Æ¤¤¤ë¾ì¹ç)¤Ë¤Î¤ßÄä»ß¤·¤Þ¤¹¡£
<P>
<P><CODE>until</CODE> ¥ë¡¼¥×¤Ï¡¢À©¸æ¼°¤¬µ¶¤Èɾ²Á¤µ¤ì¤Æ¤¤¤ë´Ö¤Ï¥³¡¼¥É¤¬¼Â¹Ô¤µ¤ì¤ë
¤È¤¤¤¦ÅÀ¤ò½ü¤¯¤È¡¢<CODE>while</CODE> ¥ë¡¼¥×¤È¤Û¤ÜƱ¤¸¤Ç¤¹¡£<CODE>while</CODE> ¤È
<CODE>until</CODE> ¤¬»÷¤Æ¤¤¤ë¤È»×¤Ã¤¿¤Ê¤é¡¢¤½¤ì¤ÏÀµ¤·¤¤¹Í¤¨¤Ç¤¹¡£
<P>
<H2><A NAME="ss7.1">7.1 For ¤Î¥µ¥ó¥×¥ë</A>
</H2>
<P>
<BLOCKQUOTE><CODE>
<PRE>
#!/bin/bash
for i in $( ls ); do
echo item: $i
done
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>Æó¹ÔÌܤǡ¢ÊÑ¿ô <CODE>i</CODE> ¤¬Àë¸À¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ë¤Ï¡¢<CODE>$( ls )</CODE> ¤Ë¤è¤Ã
¤Æ½ÐÎϤµ¤ì¤ëÍÍ¡¹¤ÊÃͤ¬(½çÈÖ¤Ë)ÂåÆþ¤µ¤ì¤Æ¤¤¤¤Þ¤¹¡£
»°¹ÔÌܤϡ¢É¬ÍפǤ¢¤ì¤Ð¤â¤Ã¤ÈŤ¯¤Ç¤¤Þ¤¹¡£¤¹¤Ê¤ï¤Á¡¢»Í¹ÔÌܤΠ<CODE>done</CODE>
¤ÎÁ°¤ËÊ£¿ô¤Î¹Ô¤¬Â¸ºß¤·¤Æ¤â¤«¤Þ¤¤¤Þ¤»¤ó¡£
»Í¹ÔÌܤΠ<CODE>done</CODE> ¤Ï¡¢ÊÑ¿ô <CODE>$i</CODE> ¤ÎÃͤò»ÈÍѤ·¤Æ¤¤¤¿¥³¡¼¥É¤¬¤½¤³¤Ç
½ªÎ»¤·¤¿¤³¤È¤ò¼¨¤·¤Æ¤¤¤Æ¤¤¤Þ¤¹¡£¤·¤¿¤¬¤Ã¤Æ¡¢<CODE>$i</CODE> ¤Ë¿·¤·¤¤ÃͤòÂåÆþ¤¹¤ë
¤³¤È¤¬²Äǽ¤Ç¤¹¡£
¾åµ¤Ï¡¢¤Ï¤Û¤È¤ó¤É°ÕÌ£¤¬¤Ê¤¤¥¹¥¯¥ê¥×¥È¤Ç¤¹¡£<CODE>for</CODE> ¥ë¡¼¥×¤ò»ÈÍѤ¹¤ë¤â¤Ã¤È
ͱפÊÊýË¡¤Ï¡¢°ÊÁ°¤ÎÎãÂê¤Ë¤¢¤Ã¤¿¤è¤¦¤Ë¡¢¤¢¤ë¼ï¤Î¥Õ¥¡¥¤¥ë¤À¤±¤òÁªÂòŪ¤Ë½èÍý¤¹
¤ë¾ì¹ç¤Ë»È¤¦¤³¤È¤À¤È»×¤¤¤Þ¤¹¡£
<P>
<H2><A NAME="ss7.2">7.2 C ¸À¸ì¤Ë»÷¤¿ for</A>
</H2>
<P>Fiesh ¤µ¤ó¤«¤é°Ê²¼¤Î¤è¤¦¤Ê·Á¼°¤Î¥ë¡¼¥×¤òÉÕ¤±²Ã¤¨¤¿¤é¤É¤¦¤«¤È¸À¤ï¤ì¤Þ¤·¤¿¡£
¤³¤Î <CODE>for</CODE> ¥ë¡¼¥×¤Ï¡¢C ¸À¸ì¤ä Perl ¤Î <CODE>for</CODE> ¥ë¡¼¥×¤ËÎà»÷¤·¤¿
»È¤ï¤ì¤«¤¿¤ò¤·¤Æ¤¤¤Þ¤¹¡£
<P>
<BLOCKQUOTE><CODE>
<PRE>
#!/bin/bash
for i in `seq 1 10`;
do
echo $i
done
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="ss7.3">7.3 while ¤Î¥µ¥ó¥×¥ë</A>
</H2>
<P>
<BLOCKQUOTE><CODE>
<PRE>
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo The counter is $COUNTER
let COUNTER=COUNTER+1
done
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>¾åµ¤Î¥¹¥¯¥ê¥×¥È¤Ï¡¢(C, Pascal, Perl ¤È¤¤¤Ã¤¿)Í̾¤Ê¸À¸ì¤Î <CODE>for</CODE> ¤Î
À©¸æ¹½Â¤¤ò¿¿»÷¤¿¤â¤Î¤Ç¤¹¡£
<P>
<H2><A NAME="ss7.4">7.4 until ¤Î¥µ¥ó¥×¥ë</A>
</H2>
<P>
<BLOCKQUOTE><CODE>
<PRE>
#!/bin/bash
COUNTER=20
until [ $COUNTER -lt 10 ]; do
echo COUNTER $COUNTER
let COUNTER-=1
done
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>
<P>
<HR>
<A HREF="Bash-Prog-Intro-HOWTO-8.html">¼¡¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO-6.html">Á°¤Î¥Ú¡¼¥¸</A>
<A HREF="Bash-Prog-Intro-HOWTO.html#toc7">Ìܼ¡¤Ø</A>
</BODY>
</HTML>
|