(一)shell脚本的分类

Shell分类:

Korn Shell (ksh)  较难  较好  好  较好 --AIX

Bourne Again (Bash)  难  较好  好  好 –centos

我们可以通过/etc/shells 文件来查询 Linux 支持的 Shell。命令如下:

[root@localhost ~]# vi /etc/shells

/bin/sh

/bin/Bash

/sbin/nologin

/bin/tcsh

/bin/csh

(1)     Shell脚本的执行方式

1、echo 命令

[root@localhost ~]# echo [选项] [输出内容]

选项:

-e:  支持反斜线控制的字符转换(具体参见表 11-2) 转义字符

-n:  取消输出后行末的换行符号(就是内容输出后不换行)

 

2:shell脚本的执行

(1)赋予执行权限

vi hello.sh

#!/bin/Bash

#The first program

echo hello world

chmod 755 hello.sh  赋予执行权限直接执行。

(2)命令执行

bash hello.sh

(3)window通过ftp编辑命令执行shell脚本提示“-bash: ./checkP.sh: /bin/sh^M: bad interpreter: No such file or directory”解决方法

vi 打开文件

:set fileformat=unix

猜你喜欢

转载自www.cnblogs.com/love-life-insist/p/11668746.html
今日推荐