「シェルスクリプトの基礎 - select文」の版間の差分

文字列「__FORCETOC__」を「{{#seo: |title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki |keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板 |description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This pag…
 
(同じ利用者による、間の2版が非表示)
7行目: 7行目:


== select文の書式 ==
== select文の書式 ==
  <source lang="sh">
  <syntaxhighlight lang="sh">
  <文字列変数>="<選択を促す文字列>"
  <文字列変数>="<選択を促す文字列>"
  <配列変数>="<配列>"
  <配列変数>="<配列>"
15行目: 15行目:
     <変数に応じた処理>
     <変数に応じた処理>
  done
  done
  </source>
  </syntaxhighlight>
<br><br>
<br><br>


== select文のサンプル(1) ==
== select文のサンプル(1) ==
以下の例では、変数STRINGに代入した内容が、select文のところで標準出力されている。<br>
以下の例では、変数STRINGに代入した内容が、select文のところで標準出力されている。<br>
  <source lang="bash">
  <syntaxhighlight lang="bash">
  #!/bin/bash
  #!/bin/bash
   
   
35行目: 35行目:
   
   
  echo "Finish script."
  echo "Finish script."
  </source>
  </syntaxhighlight>
<br>
<br>
  # 実行結果
  # 実行結果
57行目: 57行目:
変数REPLYはselect文を使用する時に、内部で生成される特別な変数である。<br>
変数REPLYはselect文を使用する時に、内部で生成される特別な変数である。<br>
この中には、ユーザが入力した値が代入される。(数字のほか文字列も表示される)<br>
この中には、ユーザが入力した値が代入される。(数字のほか文字列も表示される)<br>
  <source lang="bash">
  <syntaxhighlight lang="bash">
  #!/usr/bin/bash
  #!/usr/bin/bash
   
   
73行目: 73行目:
     esac
     esac
  done
  done
  </source>
  </syntaxhighlight>
<br>
<br>
  # 実行結果
  # 実行結果
88行目: 88行目:
  Input number: 3
  Input number: 3
<br><br>
<br><br>
{{#seo:
|title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki
|keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板
|description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This page is {{PAGENAME}} in our wiki about electronic circuits and SUSE Linux
|image=/resources/assets/MochiuLogo_Single_Blue.png
}}


__FORCETOC__
__FORCETOC__
[[カテゴリ:シェルスクリプト]]
[[カテゴリ:シェルスクリプト]]