RRonin-Chatindatainfra.hashnode.dev·May 21, 2023 · 1 min readExporting VariablesVariables are scoped within the process it is created. If you want to access a variable that is created in another script within this(new) script then you need to export that variable. code for script1.sh #!/bin/bash var1=Hello var2=World echo var1=$...00
RRonin-Chatindatainfra.hashnode.dev·May 20, 2023 · 1 min readCommand SubstitutionIn Bash, we can save the command line output of a command to a variable. This can be done by $ ( command ) dir=. count=$(ls $dir | wc -l) echo "There are $count files at location $dir" # There are 4 files at location . In the above example, we count...00
RRonin-Chatindatainfra.hashnode.dev·May 16, 2023 · 1 min readVariables in BashTo create a variable in bash, you can just assign value to the variable using (=) equal to. There shouldn't be any spaces before or after = . You can read the value inside variable by prefixing it with $ sign, the bash automatically replace $variable...00
RRonin-Chatindatainfra.hashnode.dev·May 14, 2023 · 1 min readPrinting Hello World! in BashUse echo to print anything to the command line. echo Hello World! echo "Hello World!"00
RRonin-Chatindatainfra.hashnode.dev·May 14, 2023 · 1 min readYour first Bash ScriptTo create a bash script file, open any code editor and create a new file Add the shebang (#!) at the top of the file. It tells the systems that this file should be interpreted as a Bash Script whose interpreter is located at the path after the sheban...00