#!/bin/bash
echo -e "Are you happy? \c"
read answer
echo "$answer is the right response."
echo -e "What is your full name? \c"
read first middle last
echo "Hello $first $middle $last"
echo -n "Where do you work? "
read
echo I guess $REPLY keeps you busy!
read -p "Enter your job title: "
echo "I thought you might be an $REPLY."
echo -n "Who are your best friends? "
read -a friends
echo "Say hi to ${friends[0]}."
trap 'echo "Not press Ctrl+C"' 2 //屏蔽掉Ctrl+C功能。
echo
echo "Press entery key to continue, or Ctrl+C to abort..." //充许按Ctrl+C来终止程序继续执行
read junk
clear
注:上面两个不能同时在一个脚本里出现.否则就没有意义了
result:
==========================================
[root@jp-test-apache yuhj]# sh read.sh
Are you happy? yes
yes is the right response.
What is your full name?
[root@jp-test-apache yuhj]# sh read.sh
Are you happy? happy
happy is the right response.
What is your full name? yu h j
Hello yu h j
Where do you work? China
I guess China keeps you busy!
Enter your job title: test
I thought you might be an test.
Who are your best friends? people
Say hi to people.
Press entery key to continue, or Ctrl+C to abort...
Not press Ctrl+C
评论