The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how can unset for "PS4" koti_rama UNIX for Dummies Questions & Answers 1 08-06-2007 02:12 AM
Readonly access faruque.ahmed UNIX for Dummies Questions & Answers 13 01-31-2007 08:25 AM
How to unset 'finger' info? Chanakya.m Shell Programming and Scripting 3 01-23-2006 08:12 AM
Is there any way to set env variable in top level Makefile and unset when done umen Shell Programming and Scripting 0 10-23-2005 08:15 AM
Making files readonly with vi? Flyguy UNIX for Dummies Questions & Answers 2 11-15-2003 05:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-11-2007
Registered User
 

Join Date: Sep 2007
Posts: 9
how to unset the readonly variable

Hi All,


May be this is a very simple question...

[trainee@Venus trainee]$ b=8
[trainee@Venus trainee]$ readonly b
[trainee@Venus trainee]$ echo $b
8
[trainee@Venus trainee]$ b=90
-bash: b: readonly variable
[trainee@Venus trainee]$ 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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-11-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,772
Tha man pages for bash says, once a variable is marked as readonly, it cannot be unset.

Code:
             typeset -r     Make names readonly.  These names cannot then be  assigned values by subsequent assignment statements or unset.
Also unset says

Code:
       unset [-fv] [name ...]
              For each name, remove the corresponding variable or function.  If
              no  options  are  supplied,  or the -v option is given, each name
              refers to a shell  variable.   Read-only  variables  may  not  be
              unset.
Your best option would be to kill the shell, or run the commands within a subshell. Something like

Code:
[/tmp]$ {(b=8; readonly b; echo "-$b-"); b=90; echo "[$b]"; unset b; echo "[[$b]]";}
-8-
[90]
[[]]
Reply With Quote
  #3 (permalink)  
Old 09-12-2007
Registered User
 

Join Date: Sep 2007
Posts: 9
Thanks Vino...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 07:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66