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

 

执行结果


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM