记一次shell脚本编写及执行

首先cd进一个目录下

tauch tset.sh //新建一个test.sh文件

vim test.sh 编辑脚本

i 插入

#!/bin/bash

data

按Esc键

再按ctrl+:

wq + Enter

ls -l test.sh //查看文件权限

-rw-rw-r-- 1 elasticsearch elasticsearch 18 2月 8 14:20 test.sh  //发现并没有执行权限

chmod u+rx tset.sh //只给脚本的所有者可读和执行权限

./test.sh  //执行脚本

原文地址:https://www.cnblogs.com/zzt-lovelinlin/p/8431394.html