Created
March 31, 2010 04:47
-
-
Save mobp/349948 to your computer and use it in GitHub Desktop.
標準入力からの一文字読み取り
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -s => サイレントモード | |
# -n => 読み取る文字数 | |
read -s -n1 var | |
echo "$var" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#シェルによる標準入力からの一文字読み取り(bsとcountの値で任意の文字数に変更できる) | |
getch() | |
{ | |
stty raw | |
local c=$(dd bs=1 count=1 2>/dev/null) | |
stty cooked | |
echo "$c" | |
} | |
getch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment