初识shell脚本

vim test.sh

#!/bin/bash
echo "Hello World !"

#!” 是一个约定的标记,它告诉系统这个脚本需要什么解释器来执行,即使用哪一种Shell。

 

chmod +x test.sh #使脚本具有执行权限
./test.sh #执行脚本,在当前目录找,第一行必须是#!/bin/bash
/bin/sh test.sh #执行脚本,在当前目录找,不需要在第一行指定解释器信息#!/bin/bash

 

vim test1.sh

#!/bin/bash
# Author : wx
# Date :
echo "What tools are you using?"
read tool
echo "Hello, $tool"

  

$ sh /home/wx/test1.sh
What tools are you using?
shell
Hello, shell

posted @ 2016-12-11 20:31  智能先行者  阅读(205)  评论(0编辑  收藏  举报