echo $SHELL, $PWD and etc.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers echo $SHELL, $PWD and etc.
# 8  
Old 12-17-2002
Data

Does this help, or did I read this funny?

`printenv | more`
# 9  
Old 12-30-2002
Here is the small practical example. Just check it.
Just type them on the shell & observe the output.

$a=10 (I'm creating a shell variable named as 'a' with value 10.
$set (This will show the newly created variable & its value i.e. 'a=10').
$env (This will list some set of variables other than 'a=10'.

$export a (Now Execute this statement).
$set (Now this still shows a=10 other along with some more..)
$env (Now this will show a=10 also...).

I mean, 'set' display only local & un-exported variable.
Where as 'env' shows all global & exported variable variables.

When you think of why Global & local variables, the difference
comes when using shell scripts. In a shell script if you create a
a variable, then this will be visible only for the executing script.

But, in a script if you create a variable & if you export, then it will
become a global variable, so that all scripts will be able to see this
variable.

So, using export you are making a locallly visible varialbe a Globally visible variable.

You can also do this in a single shot.

ex:- $export a=10

$ env...shows the output.

Hope this makes some sense.
# 10  
Old 12-30-2002
Now this may sound really funny..but

Can u tell me if I can unexport some variable....
I mean... suppose i did export a=10... now how to undo it.
minazk
# 11  
Old 12-30-2002
Sorry folks....!!!

I got the answer ..... unset


Regds
minazk
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to change shell's pwd

Hi there, i was presented with a challenge that is beyond my current shell knowledge: how can you have a script that executed interactive will change your current working directory? Example (under MacOS): 1. start Terminal and my current working directory is my home folder 2. execute a... (3 Replies)
Discussion started by: gigagigosu
3 Replies

2. AIX

sync samba pwd with aix5.3 pwd

currently, my samba login works just fine. i want my clients to use aix5.3 account to login to samba so they don't have to change samba pwd and aix pwd. i googled, and vi /usr/lib/smb.conf per some of knowledge base, but i could not get to work. aix5.3 and samba 3.0.24.0 thanks in advace..... (2 Replies)
Discussion started by: tjmannonline
2 Replies

3. Shell Programming and Scripting

shell echo help needed

echo '#!/usr/local/bin/expect' > sree_expt echo "spawn passwd $User" >> sree_expt echo 'expect "New password:"' >> sree_expt echo send "$Password\r" >> sree_expt echo 'expect "Re-enter new password:"' >> sree_expt echo send "$Password\r" >> sree_expt echo "expect eof" >> sree_expt for... (0 Replies)
Discussion started by: sreedhargouda
0 Replies

4. Homework & Coursework Questions

implementing mkdir, chdir, mv, pwd inside a shell !

1. The problem statement, all variables and given/known data: need to implement mkdir, chdir, mv, pwd given a shell.cpp directory.cpp and some other files this shell missing these commands, and i need to implement them inside the shell 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: evantheking
0 Replies

5. Shell Programming and Scripting

echo $PWD doesn't work

I have entry in the my .profile like below, but still i see $PWD is not defied in my system export PS1=$LOGNAME@`hostname`':'$PWD'>' echo $PWD also gives me nothing, my env list also give no entry for PWD.Can someone help me setting PWD variable. I use /bin/sh (9 Replies)
Discussion started by: yesmani
9 Replies

6. Solaris

Confused with echo $SHELL Command....

Hi.. Everyone... Kindly consider following : login as: root Using keyboard-interactive authentication. Password: Last login: Mon Nov 3 19:30:50 2008 from xxxxxxxxxxx Sun Microsystems Inc. SunOS 5.10 Generic January 2005 You have new mail. Sourcing //.profile-EIS..... # # ... (3 Replies)
Discussion started by: Reboot
3 Replies

7. UNIX for Advanced & Expert Users

echo ${PWD#${PWD%/*/*}/}

Can anyone explain this in detail ... echo ${PWD#${PWD%/*/*}/} Thanks in Advance (1 Reply)
Discussion started by: sakthi.abdullah
1 Replies

8. Shell Programming and Scripting

pwd & cd commands not working in shell script

Here is my script #!/bin/bash pwd cd /var/lib/pgsql Both "pwd" and "cd" are not executed is there any other way i can change the current working directory to /var/lib/pgsql pls help! (9 Replies)
Discussion started by: perk_bud
9 Replies

9. Shell Programming and Scripting

Shell and echo

Probably my first post, very new to shell scripting :) Here is the script i am trying to modify to use function # Script to create simple menus and take action according to that selected # menu item # while : do clear echo "-------------------------------------" echo "... (2 Replies)
Discussion started by: replyramdas
2 Replies

10. UNIX for Advanced & Expert Users

Echo with ksh shell

Hi All, I'm trying to use the "echo" command in a korn shell script, and I want it to drop the trailing newline. Now I know that with the bash shell, the "-n" flag would solve this issue. Does anyone know how this can be done with the korn shell? Cheers Khoom (10 Replies)
Discussion started by: Khoomfire
10 Replies
Login or Register to Ask a Question