Use
An environment variable is a dynamic "object" on a computer, which refers to the system checking some protocols like where to find the particular program, where to save the temporary files and many more. We set up some environment variables while installing the interpreter or compiler for any language like Java, C++, etc. Generally, it is denoted as $PATH(UNIX & LINUX) or PATH(Windows). The cool part of environment variables is we can make our own like any other programming variables and set some values to them. We can do some automation and some really cool stuff.
Benefits
- Easy to use.
- It increases efficiency.
Example
If you are working on a project, where you are writing some python automation script and using some specific folder to create logs, save and move the modified file from one directory to another. So, you can set some environment variables for the same and use them in your script.
How to Make it:
export ORA=$ORA /mnt/c/Users/Admin/Oracle
This will set a variable _$ORA _with the value - /mnt/c/Users/Admin/Oracle
How to check the value:
echo $ORA
This will print the value of the $ORA which is /mnt/c/Users/Admin/Oracle
How to use it:
cd $ORA
cd is known as change directory, so the above command changes the directory to its value(your desired path) and goes to the Oracle folder.
How to delete it:
export ORA=${ORA% /mnt/c/Users/Admin/Oracle}
The above command will delete the value from the variable. I have put this command just because I messed up a big-time and I had to research out how to revert back or change the variable values.
So, this is it from my end till now on this topic. If you want to add something please feel free to share. If I got some more updates then I will update the article. Thanks for reading and enjoy my write-up.
Top comments (0)