Bash – How to Delete Readonly Variable in Bash

bashlinuxshell

$ mySite="superuser"
$ readonly mySite
$ unset mySite
bash: unset: mySite: cannot unset: readonly variable

How can we delete mySite, as it is a readonly variable?

Best Answer

You can't delete mySite. The whole point of the readonly command is to make it final and permanent (until the shell process terminates). If you need to change a variable, don't mark it readonly.

Related Question