[ask] about unset variables

I'm wondering, is the number of variables will affect execution time of my bash script or maybe affect the cpu workload, cpu memory, etc ?

If I create so many variables, should I unset each one of that variables after I used them or after I think they are no longer needed?

and if my script called another script which in that script there are also many variables, are these variables will remain available after that script successfully executed?

or,

Should I just ignore all about this variables things and just keep on writing my script as I wanted to be?

Usually programmers worried about performance and efficiency would opt for a robust programming language like C or its siblings. Scripts are usually (I'd dare not say "only") used for achieving relatively smaller tasks.

A comical side note: You may do what it takes to possess the three great virtues of a programmer - laziness, impatience, and hubris :smiley:

Assigning the values to a variable inside the sript will get unset once execution of that script gets completed ..

Below is the sample demo for that ..

$ var=outside_script
$ echo $var
outside_script
$
$ cat infile
var=inside_script
echo "Var : $var"
$
$ sh infile
Var : inside_script
$
$ echo $var
outside_script
$

Hence you can declare more variables as you want .. but a good programmer will reduce the more usage of variables in script.. :wink: