!/bin/bash
echo "Please type a word!"
read word
echo "You just typed $word"
echo "Please type two words!"
read word1 word2
echo "You just typed $word1 $word2"
[jerry@localhost bin]$ ./reply_test.sh
./reply_test.sh: line 1: !/bin/bash: No such file or directory
Please type a word!
word
You just typed word
Please type two words!
word1 word2
You just typed word1 word2
echo "Please type a word!"
read word
echo "You just typed $word"
echo "Please type two words!"
read word1 word2
echo "You just typed $word1 $word2"
[jerry@localhost bin]$ ./reply_test.sh
./reply_test.sh: line 1: !/bin/bash: No such file or directory
Please type a word!
word
You just typed word
Please type two words!
word1 word2
You just typed word1 word2
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23895263/viewspace-697718/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23895263/viewspace-697718/
本文介绍了一个简单的Shell脚本示例,演示了如何读取用户输入并显示所输入的内容。通过这个例子,读者可以了解基本的Shell脚本语法,包括变量赋值、条件判断等关键概念。
1674

被折叠的 条评论
为什么被折叠?



