while read line
do
...
done
在 csh 中,則用 $<:
while ( 1 )
set line = "$<"
if ( "$line" == "" ) break
...
end
很可惜的,csh 並沒有方法判斷空白行和檔案結尾(end-of-file)的不同。
如果你要用 sh 從 terminal 讀一個字元,那麼你可以試試
echo -n "Enter a character: "
stty cbreak # or stty raw
readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty -cbreak
echo "Thank you for typing a $readchar ."
參考示例 : http://www.5h6.com/article/10118.html