I want to know how to clear all variables which I defined in command prompt without closing terminal ?
for example, if I set a variable in command prompt as:
$ a=1
now I want to delete the variable $a (and many other variables defined in similar way) without closing terminal. I could use unset but it will be hectic if there are large no. of variables
exec "$0"maybe - but it's hard to tell what you mean by global. – mikeserv Dec 10 '14 at 23:07execis what you want. I once did an answer in detail on this. maybe look - it was all about clearing the shells memory. – mikeserv Dec 10 '14 at 23:13$varwithvar=$(declare -p +F);then passes that as an argument to a function which doesecho "${2%%=*}".That answer has a few problems with sheer size - but it should work if your environment isn't huge. – mikeserv Dec 10 '14 at 23:34exec "$0"works. can you please explain it in answer how ? – Alex Jones Dec 10 '14 at 23:36setpart in the link I left - that's what migrates vars from old shell to new. – mikeserv Dec 10 '14 at 23:37