With local and environment variables. How are they created and assigned? Are the
ID: 3646504 • Letter: W
Question
With local and environment variables. How are they created and assigned? Are they used internally or externally to the shell? What are their purposes?Also can i see some examples? JavaExplanation / Answer
A local variable is confined to a session. It means if u create a variable, it will be available for that session. If you restart the shell, it is longer available. Whereas, an environment variable once created will be forever. No need to create it for every new shell while a local variable needs to be created everytime a new shell is used. Setting a local variable: SET variable_name = value Ex: SET a=76 To display, ECHO %variable_name%. Ex: ECHO %a% Setting a environment variable: Go to Mycomputer--right-click>properties>advanced tab>environment variables>system variables>new: Now, write variable_name in variable name Variable value in value. Ex: Variable name: a Variale value: 76 This a can be used anytime. We can also use environment variables to have shortcuts. For example, if we want to open notepad instantly, do this: Again go to environment variables and click new under user variables. variable name : notepad Variable value: C:WindowsSystem32 otepad.exe This will help you open notepad just by typing this in the shell. Like this you can have many shortcuts using the file path in variable value.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.