|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
export vs env vs set commands
Hi I'm trying to understand variable scopes in solaris10. It is said that to display env variables we use 3 commands : - env - set - export What is the difference between them ? thx for help. ---------- Post updated at 11:00 AM ---------- Previous update was at 10:50 AM ---------- I understand this : To list all shell vars with their current values perform set cmd. Code:
# set HOME=/root HZ= IFS= LC_COLLATE=pl_PL.ISO8859-2 LC_CTYPE=pl_PL.ISO8859-2 LC_MESSAGES=C LC_MONETARY=pl_PL.ISO8859-2 LC_NUMERIC=pl_PL.ISO8859-2 LC_TIME=pl_PL.ISO8859-2 LOCAL=local_variable LOGNAME=root MAIL=/var/mail/root MAILCHECK=600 OPTIND=1 PATH=/usr/sbin:/usr/bin PS1=# PS2=> REMOTE=remote_variable SHELL=/sbin/sh TERM=ansi TZ=Poland To make a value of variable known to a subshell export it using the export cmd. Code:
# export export LOGNAME export PATH export REMOTE QUESTIONS --------------- Now I understand the difference between set and export cmds but don't understand the meaning of env command ? What does it mean to make a value of variable known to a sub-shell ? Last edited by presul; 06-18-2011 at 07:06 AM.. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Quote:
Code:
[root@linux ~]# x=5 <= here variable is set without export command [root@linux ~]# echo $x 5 [root@linux ~]# bash <= subshell creation [root@linux ~]# echo $x <= subshell doesnt know $x variable value [root@linux ~]# exit <= exit from subshell exit [root@linux ~]# echo $x <= parent shell still knows $x variable 5 [root@linux ~]# export x=5 <= specify $x variable value using export command [root@linux ~]# echo $x <= parent shell doesn't see any difference from the first declaration 5 [root@linux ~]# bash <= create subshell again [root@linux ~]# echo $x <= now the subshell knows $x variable value 5 [root@linux ~]# |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
ok @bartus11 I understand now the difference but have one more question :
Command set shows all declared variables, command export shows only declared and exported variables but what shows env command ? |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cat and export | steven_TTG | UNIX for Dummies Questions & Answers | 3 | 02-27-2009 08:58 PM |
| Can BASH execute commands on a remote server when the commands are embedded in shell | bash_in_my_head | Shell Programming and Scripting | 1 | 12-04-2008 12:51 AM |
| About export | Arunprasad | Shell Programming and Scripting | 3 | 11-05-2008 02:18 AM |
| export script commands with xterm | chris2051 | UNIX for Dummies Questions & Answers | 1 | 10-09-2008 07:15 AM |
| code that reads commands from the standard i/p and executes the commands | Phrozen Smoke | Programming | 4 | 01-22-2007 01:06 AM |
|
|