我是新手,我目前正在学习如何在UNIX中编写脚本。我使用像Vim这样的工具来编写脚本。让我们说像
#!/bin/bash
echo -e "Hi, please type the word: \c "
read word
echo "The word you entered is: $word"
echo -e "Can you please enter two words? "
read word1 word2
echo "Here is your input: \"$word1\" \"$word2\""
echo -e "How do you feel about bash scripting? "
read
echo "You said $REPLY, I'm glad to hear that! "
echo -e "What are your favorite colours ? "
read -a colours
echo "My favorite colours are also ${colours[0]}, ${colours[1]} and ${colours[2]}:-)"
需要用户输入变量的地方。
我的问题是,如何执行此脚本?我是通过在Windows中的Vim或cmd中放置命令来执行此操作,这是什么命令?谢谢你的帮助!
答案 0 :(得分:1)
我建议安装像http://www.cygwin.com/这样的UNIX shell 然后,您可以使用以下命令
执行bash脚本script_name.sh
当您在保存脚本的目录中时,只需在shell中输入它即可。