サンプルスクリプトです。あくまで、自己責任で実行してください。
Yes/No を判定するシェルスクリプト
例の内容 Yesと入力した場合は、/root/anaconda-ks.cfgファイルの末尾5行を読み込む。 Noと入力した場合は、exitで抜ける。
#!/bin/sh FileNAME=/root/anaconda-ks.cfg echo "$FileNAME" read FileNAME echo "tail file ? [y/n]" read ANSER if [ $ANSER = 'y' -o $ANSER = 'yes' ]; then tail /root/anaconda-ks.cfg fi if [ $ANSER = 'n' -o $ANSER = 'no' ];then echo "finsh!!";exit fi
