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 @ 2024-01-21 12:57  小鲨鱼2018  阅读(52)  评论(0编辑  收藏  举报