Where unset command locates?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Where unset command locates?
# 1  
Old 05-20-2015
Where unset command locates?

Hi,

Can someone tell what is the path for "unset", I tried "which" command but getting below error

Code:
 
# which unset
/usr/bin/which: no unset in (/usr/lib/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin/:/root/bin)

# 2  
Old 05-20-2015
Hi,

on Debian Linux + Bash:
Code:
type unset
unset is a shell builtin

This User Gave Thanks to cero For This Post:
# 3  
Old 05-20-2015
Yes, it's a shell built-in, much like set is.

Code:
$ type set
set is a special builtin

$ type unset
unset is a special builtin

(ksh on Solaris)
# 4  
Old 05-20-2015
It alters values inside the shell itself, so it pretty much has to be a builtin. So does cd. (There is sometimes a cd utility too, but it's used for other purposes.)
# 5  
Old 05-20-2015
Quote:
Originally Posted by Corona688
It alters values inside the shell itself, so it pretty much has to be a builtin. So does cd. (There is sometimes a cd utility too, but it's used for other purposes.)
The standards require that "standard utilities" have to be available as stand-alone utilities so you do things like:
Code:
find dir -exec utility arg... \;

The only utilities defined by the standards that are excluded from this requirement are the special built-ins: break, colon, continue, dot (i.e., .), eval, exec, exit, export, readonly, return, set, shift, times, trap, and unset.
And, before you say it doesn't make any sense to use cd in a find -exec primary, the command:
Code:
find dir ! -exec cd {} \;

is a simple way to get the names of inaccessible directories in the file hierarchy rooted in the directory named dir.
These 4 Users Gave Thanks to Don Cragun For This Post:
# 6  
Old 05-21-2015
what is difference between
Code:
env -u TEST

and
Code:
unset TEST

when I run "env -u TEST" and do "env|grep TEST", get "TEST=tesvalue"

when I run "unset TEST", didn't any o/p for "env|grep TEST" command.
# 7  
Old 05-21-2015
env creates a new environment, unsets the TEST variable in it, and runs whatever command you gave it in that new environment.

Since you gave it no command, that new environment immediately quits without doing anything else, leaving you back in your original one.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unset environement variable

Hi, I have the following line in the script unset _SET_ENV_AA unset _SETENV but where I can check the value for this environement variable (2 Replies)
Discussion started by: stew
2 Replies

2. Red Hat

PROC_MEM_RES how to set/unset/change

Hi all, Does anyone know how to change PROC_MEM_RES? We have a DB server with quite a few oracle instances (RAC) and we are getting critical alerts for PROC_MEM_RES. Anyone know how to increase the current setting or what we should do about it? Thanks in advance. john (2 Replies)
Discussion started by: jonnyd
2 Replies

3. Shell Programming and Scripting

Unset variable with characters in value

I have a script with a $PASSWORD variable. I unset it right after using it, just to minimize the chance it could be left around for a snooper. That worked just fine... until I used a password with a value of "P@ssw0rd" Now, unset (even with -f, even with the variable enquoted) tells me: unset:... (1 Reply)
Discussion started by: jnojr
1 Replies

4. Shell Programming and Scripting

[ask] about unset variables

I'm wondering, is the number of variables will affect execution time of my bash script or maybe affect the cpu workload, cpu memory, etc ? If I create so many variables, should I unset each one of that variables after I used them or after I think they are no longer needed? and if my script... (2 Replies)
Discussion started by: 14th
2 Replies

5. UNIX for Advanced & Expert Users

unset .bashrc

Could someone please tell me how to unset your .bashrc? I have tried all of these. I can't find anything useful from google. unset -f .bashrc unset .bashrc (9 Replies)
Discussion started by: cokedude
9 Replies

6. Shell Programming and Scripting

How to unset all variables in shell?

can I use unset to unset all the variables in a shell sciprt? VAR1=1 VAR2=2 VAR3=3 unset whether this unset will afftect any system variables? Thanks, (3 Replies)
Discussion started by: balamv
3 Replies

7. Solaris

how to unset maxuprc in solarsi zones

As of Solaris 9,10 in /etc/system file I can comment the “set maxuprc” for the restriction. But in Solaris zones how I can unset the variable “maxuprc” because /etc/system file is not there. How I can proceed. Regards, Kalai (1 Reply)
Discussion started by: kalpeer
1 Replies

8. Shell Programming and Scripting

Using unset to delete array elements

Hi, I am writing a BASH script. My questions regard deleting elements of arrays. I have an array: michael-browns-powerbook-g4-15:~ msb65$ test_array=(1 2 3 4) michael-browns-powerbook-g4-15:~ msb65$ echo ${test_array} 1 2 3 4 To delete the second element of test_array I type:... (3 Replies)
Discussion started by: msb65
3 Replies

9. UNIX for Advanced & Expert Users

how to unset the readonly variable

Hi All, May be this is a very simple question... $ b=8 $ readonly b $ echo $b 8 $ b=90 -bash: b: readonly variable $ unset b -bash: unset: b: cannot unset: readonly variable I m not able to change the readonly mode of variable b Please help me out.. Thanks Nidhi (2 Replies)
Discussion started by: Nidhi2177
2 Replies

10. Shell Programming and Scripting

How to unset 'finger' info?

Hi, Command "chfn" can be used to change finger information.. can anybody tell me how to unset i mean reset the same finger information. Thanks in advance, Chanakya (3 Replies)
Discussion started by: Chanakya.m
3 Replies
Login or Register to Ask a Question