pass parameters to shell scripts ?
Hi guys.
how do i pass a parameter to a shell script, in a way that the shell script will then pass that parameter to an executable ??? thanX |
With bash you can access them with $n. Where 0 is the script itself and 1,2...so on are the arguments passed
|
suppose you have the shell script test.sh
test.sh: #!/bin/sh echo "you passed the parameter $1"; now execute the file ./test.sh hello this will print you passed the parameter hello to pass it to other programs: #!/bin/sh echo "parameter $1" /usr/bin/find $1 now, when you execute $./test.sh \/etc\/ it will print parameter /etc/ and then execute 'find' with the parameter /etc/ (will display all the files in /etc/) |
All times are GMT -5. The time now is 03:35 AM. |