The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 09:25 AM
How to unset 'finger' info? Chanakya.m Shell Programming and Scripting 3 01-23-2006 09: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 06:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-11-2007
Nidhi2177 Nidhi2177 is offline
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
  #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,796
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]
[[]]
  #3 (permalink)  
Old 09-12-2007
Nidhi2177 Nidhi2177 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 9
Thanks Vino...
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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