Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to declare global variables in a Shell Script

851268Apr 1 2011 — edited Apr 4 2011
Hi All,

I have been using export command to declare variables for setting up the log folder path, data directory path, archive folder path, scripts folder path etc. in my shell scripts. E.g.
export datadir=(path1)
export archive=(path2)
export logs=(path3)
However, these variables with the same paths are used in multiple scripts, and with a small change in directory structure I have to reflect the changes across all the shell scripts. I would like to assign these variables as a global variables and want to maintain them at a single place, so that if any change comes I have to make ammendments at a single place rather than across all the files.

For example, I have aliased some routinely used directory path with ALPHABETS in my .profile, and whenever I log on to the session I run . .profile and then just have to type in those aliased alphabets to reach those directory paths. And in case any folder structure changes I have to make a change in .profile file only.

I need a solution something like this, I am litlle new to shell programming. Have googled how to declare kind of global variables in a shell script, but could'n get to the right link.
Also, could these variables be used in the sql*loader control file?

Please help.
Thanks,
Saurabh.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 2 2011
Added on Apr 1 2011
8 comments
980 views