Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-14-2009, 07:14 PM
|
#1
|
LQ Newbie
Registered: Dec 2009
Posts: 5
Rep:
|
how can i create a global variable called "dogpatch" with a value of "woof"
how do i create a global variable called "dogpatch" with a value of "woof" (in red hat, I am new at this and am trying to figure it out but i need help.
|
|
|
12-14-2009, 07:16 PM
|
#2
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
Hi, welcome to LQ
You must tell us what language you're writing your code in, as there's likely going to be some semantic and syntactic differences from language to language.
Sasha
|
|
|
12-14-2009, 07:33 PM
|
#3
|
LQ Newbie
Registered: Dec 2009
Posts: 5
Original Poster
Rep:
|
[QUOTE=earthdog;3791589]how do i create a global variable called "dogpatch" with a value of "woof" (in red hat, I am new at this and am trying to figure it out but i need help.[/QUOT
i am writing my code in english
earthdog
|
|
|
12-14-2009, 07:41 PM
|
#4
|
LQ Newbie
Registered: Dec 2009
Posts: 5
Original Poster
Rep:
|
[QUOTE=earthdog;3791607]
Quote:
Originally Posted by earthdog
how do i create a global variable called "dogpatch" with a value of "woof" (in red hat, I am new at this and am trying to figure it out but i need help.[/QUOT
i am writing my code in english
earthdog
|
i am writing my code in linux
|
|
|
12-14-2009, 07:53 PM
|
#6
|
LQ Newbie
Registered: Dec 2009
Posts: 5
Original Poster
Rep:
|
Quote:
Originally Posted by chrism01
|
right on, Im using the Korn shell
Earthdog
|
|
|
12-14-2009, 07:56 PM
|
#7
|
LQ Newbie
Registered: Dec 2009
Posts: 5
Original Poster
Rep:
|
Quote:
Originally Posted by earthdog
right on, Im using the Korn shell
Earthdog
|
I get it know thanks chrism01
|
|
|
12-14-2009, 09:45 PM
|
#8
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,441
|
Well, korn is highly compatible with bash, but see http://kornshell.com/ for more ksh docs than you ever wanted 
Also, please click the Blue Thumbs-up on someone's post to thank them as well.
|
|
|
12-14-2009, 09:50 PM
|
#9
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
The term "global variable" has a specific meaning in programing: I suspect what you are trying to do with ksh, is actually something a little different, since usually in shell scripts all variables are global. So, can you tell us what you are actually trying to achieve?
Evo2.
|
|
|
12-15-2009, 01:03 AM
|
#10
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,441
|
Seeing as we've established ksh (yes ?), the nearest thing to a 'global' var is to 'export' it.
A var set/declared in a given shell level is avail to the code at that level.
You can export it, but this only makes it available to any sub-shells called from the current env. You cannot export (or 'return') a var upwards in the shell tree.
This is true of shell scripting generally ie bash, ksh, sh etc.
See the docs I linked to.
|
|
|
All times are GMT -5. The time now is 07:21 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|