Bash scripting
Using our own variable:
- In the terminal we can create our own variable.
- if we call the variable it reflects the value.
- This cannot be used inside a bash script. Since it is a parent variable and the child function that is inside script cannot use it.
- To use a variable which is declared outside can be done by using export command.
- Command : export <variable_name>
- But,These variable will be removed once we logout.
- To make a variable which is permanently available.We can edit the ".bashrc" file in home directory.
- If a file name start with a period(".").This means the file is hidden.
- The hidden file will not be visible on "ls" command.
- To display hidden files "ls -al" can be used .
- Edit the script with any file editot like nano.
- nano .bashrc
- At last ,add "export <variable_name> = <variable_value>"
- Restart the machine.
- So we can can use the variable outside.
Using command output has variable Value:
No comments:
Post a Comment