Showing posts with label Command prompt. Show all posts
Showing posts with label Command prompt. Show all posts

Monday, October 17, 2016

Bash (Unix shell): Select Menu Example: Variable

Command:

$ select item in {a..z}; do echo $item ":" $REPLY; done


Result:

1) a    3) c   5) e   7) g   9) i  11) k  13) m 15) o 17) q  19) s  21) u  23) w  25) y
2) b    4) d   6) f   8) h  10) j  12) l  14) n 16) p 18) r  20) t  22) v  24) x  26) z
#?


User input:

1


Result:

a : 1

Bash (Unix shell): Changing Command Prompt

Command:

$ PS1="( ^ω^ ) "


Result:

( ^ω^ )


Command:

( ^ω^ ) PS1="$ "


Result:

$

Bash (Unix shell): Select Menu Example: PS3

Command:

$ PS3="please select item > "; select item in "item1" "item2" "item3"; do if [ $REPLY = "q" ]; then break; fi; done;


Result:

1) item1
2) item2
3) item3
please select item >


User input:

1


Result:

please select item >


User input:

q

Bash (Unix shell): Command prompt (コマンドプロンプト)

Command:

$ read -p "Do something? "; if [ $REPLY == "y" ]; then echo yay; fi


Result:

Do something?


User input:

y


Result:

yay