Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Script and Passing Variable

Status
Not open for further replies.

saw15

Technical User
Jan 24, 2001
468
US
We run multiple shell scripts, but I would like to know how you can run the shell script, passing in a variable from the command line and then using the variable within the script.

Example:

$ myshellscript.sh (is currently how we call script).

I would like to pass script and dbName:
$ myshellscript.sh databaseName

With this passed, how do I reference the variable within the script?

Thanks in advance.

 
with $1, example:

hello.sh

#!/bin/ksh
echo Hello $1

Then:
$./hello.sh saw15

Hello saw15

Cheers.

Chacal, Inc.
 
Thanks for the quick response... just remembered.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top