linux下shell编程基础入门

查看当前系统shell运行类型

[vagrant@localhost ssh]$ echo $BASH
/bin/bash

第一个shell脚本

[vagrant@localhost ssh]$ vi first_shell.sh

#!/bin/bash
echo 'hello world'

[vagrant@localhost ssh]$ ./first_shell.sh
hello world

[vagrant@localhost ssh]$ /bin/bash first_shell.sh
hello world
脚本编写完毕,如何来执行呢,首先执行 shell 脚本需要执行权限,
赋予执行权限:
chmod o+x first_shell.sh 然后./first_shell.sh 执行即可;也可
以直接使用命令执行: /bin/sh first_shell.sh,显示效果一样。

 

猜你喜欢

转载自www.cnblogs.com/ksy-c/p/13191334.html