shell脚本编写保存

#!/bin/bash

echo "Shell参数实例";
echo "文件名:$0";
echo "参数个数:$#";
echo "参数列表:$*";

~
~
~
:w test.sh     

使用vi编写shell脚本,保存为test.sh

 

root@eduyun:/home/temp# ./test.sh 1 2 3 
bash: ./test.sh: Permission denied

上面显示没有权限执行此脚本

 

root@eduyun:/home/temp# chomd +x test.sh
No command 'chomd' found, did you mean:
 Command 'chmod' from package 'coreutils' (main)
chomd: command not found
root@eduyun:/home/temp# chmod +x test.sh

给test.sh分配执行权限,注意命令不要输错!

 

root@eduyun:/home/temp# ./test.sh 1 2 3 4
Shell参数实例
文件名:./test.sh
参数个数:4
参数列表:1 2 3 4

 

执行结果

posted @ 2017-10-11 10:48  Againn  阅读(7644)  评论(0编辑  收藏  举报