Variables

Variable Scoping

Another hiddem gem in BASH, is that you can scope variables, using thelocal keyword:

my_variable="Global value"
functionmy_function()
{
localmy_variable="My function local value"
echo"my_variable=$my_variable"
}
my_function
echo"my_variable=$my_variable"
my_function

~ /home 🏠 ~ talks πŸ’¬ ~ bash ~ craftsmanship ~ db ~ dongxi ~ emacs ~ escenic ~ iam ~ java ~ js ~ language ~ latex ~ ldap ~ life ~ linux ~ llm ~ mac-os-x ~ mt-foo ~ network ~ norsk ~ python ~ quotes ~ running ~ security ~ travel ~ unix ~ various ~ vcs ~ webdesign ~ windows ~ discoveries ~ cv πŸ§™ ~

Licensed under CC BY Creative Commons License ~ πŸ“‘ RSS feed ~ βœ‰ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ πŸŽ₯ youtube.com/@skybert

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /