Shell scripts can also receive script parameters, like commands and applications, as they are executed .
An application example:
VI addhead.sh:
Suaddhead ns=591 <$1 |sushw key=dt a=20000|sushw key=fldr,cdp a=1,1 b=0,1 c=1,0 j=1301,1301> $
Perform:
./addhead.sh Rtm_step10_lap.dat rtm_step10_lap.su (where rtm_step10_lap.dat is input data, input to $ $, output: rtm_step10_lap.su)
The tutorials are as follows:
You can use a system-defined positional variable, which is a special type of variable, and you can use the 9 variable to $9 when referencing a script parameter.
Example: Cat example1.sh
#!/bin/bash
#Demonstrate the use of positive variables.
echo "The first parameter:" $
echo "The second parameter:" $
echo "The third parameter:" $
echo "The fourth parameter:" $4
In the above script, the 1th 2 3 4 parameters that were passed to the script file are captured and output by using the $ $ $ $4.
Perform:
#为脚本文件添加可执行权限
chmod u+x example1.sh
#./example1.sh one three four
The first Parameter:one
The second Parameter:two
The three Parameter:three
The fourth Parameter:four
Example 2:example2.sh
Echo ' $ ' = ' $ ' $ ' = ' $ ' $ ' "=" $ $
echo ' $4 ' = ' $4 ' "=" $ $6 ' "=" $6
echo ' $7 ' = "$7 ' $8 '" = "$8 ' $9 '" = "$9
Run:
./example2.sh a b c d e F g h i
Get:
$ = A $ = b $ = c
$4 = d = $ = e $6 = f
$7 = g $8 = h $9 = i
When the shell script executes, passes parameters to the script