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

相关文章:

  • 2021-05-07
  • 2021-10-07
  • 2021-07-05
  • 2021-11-10
  • 2021-07-09
  • 2021-11-03
  • 2021-11-17
  • 2021-08-03
猜你喜欢
  • 2021-07-25
  • 2022-12-23
  • 2021-08-06
  • 2021-12-25
  • 2021-04-10
  • 2022-01-17
相关资源
相似解决方案