LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-21-2008, 02:30 PM   #1
hocheetiong
Member
 
Registered: Jul 2007
Location: Penang , Malaysia.
Distribution: red hat linux
Posts: 133

Rep: Reputation: 15
Smile How to remove readonly variable?


Hi,

# var1=super
# var1=

1.first i assign var1=super, than i assign var1 to nothing.


# var1=super
# readonly var1
# var1=
-bash: var1: readonly variable
# unset var1
-bash: unset: var1: cannot unset: readonly variable


2. Now i assign var1 as readonly variable, than if i really want to change or remove this variable how to do?


Thank.
 
Old 04-21-2008, 04:04 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by hocheetiong View Post
2. Now i assign var1 as readonly variable, than if i really want to change or remove this variable how to do?
Don't declare it as readonly. Once you've set a variable as readonly you can't do anything but kill the shell.

The only chance is to use readonly variables in a subshell. In this case the variable is local to the subshell and the parent shell is not aware of its existence:
Code:
( var=3; readonly var; echo $var )
var=5
echo $var
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I remove a variable from PATH melinda_sayang Slackware 17 02-28-2009 12:55 PM
readonly boot karlan Linux - General 1 03-10-2004 09:09 AM
Readonly drives Andy@DP Linux - Newbie 1 08-23-2003 07:52 PM
how to remove PATH variable? greg108 Linux - Newbie 2 08-22-2003 01:55 PM
unset a readonly variable hamster Linux - General 2 05-19-2003 05:13 PM


All times are GMT -5. The time now is 01:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration