How to use parameters in the script?

 

The first parameter: $ 1, the second argument: $ 2

test.sh

echo $ 1 
echo $ 2

Export

bogon:Desktop macname$ ./test.sh 23 45
23
45

 

 

Example: script copies the file (arg1) to the target address (arg2)

copy.sh

#!/bin/bash
cp $1 $2

run

./copy.sh file1.txt /tmp/

 



 

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/12003146.html