简单的shell脚本编写和执行
vi simpleshell.sh
1 #!/bin/bash 这里不是注释,这句话的作用是标注接下来写的内容是shell脚本,不可省略
2 #Author:PingFanzzz
3
4
5 echo 'This is my first Shell script '
wq保存退出后修改权限
chmod 755 simpleshell.sh
执行结果:
[root@localhost sh]# ./simpleshell.sh (相对路径执行)
This is my first Shell script
[root@localhost sh]# /root/sh/simpleshell.sh(绝对路径执行)
This is my first Shell script
[root@localhost sh]# bash simpleshell.sh(bash执行,可以不给simpleshell赋予执行权限)
This is my first Shell script
windows编写好的脚本转换成Linux脚本
yum -y install dos2unix
dos2unix 脚本名称 可以将windows下编写的脚本转换成为Linux可以执行的脚本