Linux 中 使用set 给shell脚本设置参数

 

001、

复制代码
[root@PC1 test1]# ls                        ## 准备两个测试文件
a.sh  b.sh
[root@PC1 test1]# cat a.sh                  ## a文件
#!/bin/bash

echo $*
[root@PC1 test1]# cat b.sh                  ## b文件
#!/bin/bash

set one two three

echo $*
[root@PC1 test1]# bash a.sh

[root@PC1 test1]# bash a.sh one two three     ## 执行a文件,需要位置参数
one two three
[root@PC1 test1]# bash b.sh                   ## b文件不需要,因为使用set指定了参数
one two three
复制代码

 

 

 

posted @   小鲨鱼2018  阅读(110)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-01-21 利用 UltraISO 制作linux U盘的启动盘
2023-01-21 windows中如何关闭 BitLocker
2023-01-21 syslinux引导扇区不支持NTFS文件系统
2023-01-21 找到多余1个分区
2023-01-21 ubuntu 中 putty登录 No supported authentication methods available
2023-01-21 sshd: no hostkeys available -- exiting. [fail]
2023-01-21 ubuntu 中 如何查看是否安装了ssh服务、服务状态
点击右上角即可分享
微信分享提示