Firstly, I have defined a variable count=10 and made it readonly. Now, how can I unset it?
Secondly, on unsetting a variable it sets it to NULL string. I have set dir=/home/kundan
Now on unsetting dir, if I do echo $dir, output is null, but if I give cd $dir it goes to /home/kundan.
Why is this happening?
I expected that after unsetting dir it should not go to /home/kundan
Unset is working as expected as it sets the @dir to null. It wont work if the variable is a readonly variable.
on cd $dir , if the $dir is empty or if it doesn’t exist . It will go to the default directory. i.e. /home/username.
Just try cd $abcd(where $abcd is not defined) from a different path , since $abcd is not defined , it will end up in /home/username