bash script

Deceiver

Senior member
Mar 4, 2000
385
0
0
How do I input variables from the command line into a bash script? Right now I have a variable declared in the script that I have to change each time I run it and it would be nice to specify this variable through the command line as I run it.
 
Mar 14, 2002
54
0
0
Really simple....

Use the $<number> notation.

[12:02pm] kelly (~) # sh test.sh hello again

The first argument is hello , the second argument is again

[12:02pm] kelly (~) # cat test.sh
#!/bin/sh

echo ""
echo "The first argument is $1 , the second argument is $2"
echo ""
exit 0