1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

プロンプト入力で違った結果を表示させる

Last updated at Posted at 2015-08-21

備忘
とりあえず、プロンプトで入力(green,red,yellow)を求めて該当した入力で分岐する。
\green,red,yellowの頭文字を正規表現にするにはどうすればいいのか。。。

#!/bin/bash

while :
 do
 echo "input signal (green/yellow/red)"
 read signal
  case $signal in
   [Rr]ed)
   echo "Stop"
   ;;
   [Gg]reen)
   echo "Go!"
   ;;
   [Yy]ellow)
   echo "Caution"
   ;;
   *)
   echo "end"
   ;;
  esac
 break;
 done

Output 1
# ./input.sh 
input signal (green/yellow/red)
green
Go!
Output 2
# ./input.sh 
input signal (green/yellow/red)
yellow
Caution
Output 3
# ./input.sh 
input signal (green/yellow/red)
red
Stop
1
1
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?