Loading bash-scripting.md +14 −3 Original line number Diff line number Diff line # Bash-scripting ### Variables ```bash # There can't be any space between the variable name and the equal sign. It has to be varname=command battery_time=$(cat /sys/class/power_supply/BAT0/capacity) # The variables cna then be used like this echo "$battery_time" ``` ## Iterate over a file This script will iterate over a file and echo out every single line: Loading Loading @@ -47,7 +59,6 @@ done `$1` here represent the first argument. ```bash if [ "$1" == "" ]; then echo "This happens" fi Loading @@ -65,7 +76,6 @@ else fi ``` ## Command line arguments Command line arguments are represented like this Loading @@ -75,6 +85,7 @@ Command line arguments are represented like this $1 ``` This is the first command line argument. ## Daemonize an execution Loading @@ -89,7 +100,6 @@ for ip in $(cat ips.txt); do done ``` ## Use the output of command It has happened to me several times that I want to input the output of a command into a new command, for example: Loading @@ -111,3 +121,4 @@ cat $(locate 646.c | tail -n 1) ``` Loading
bash-scripting.md +14 −3 Original line number Diff line number Diff line # Bash-scripting ### Variables ```bash # There can't be any space between the variable name and the equal sign. It has to be varname=command battery_time=$(cat /sys/class/power_supply/BAT0/capacity) # The variables cna then be used like this echo "$battery_time" ``` ## Iterate over a file This script will iterate over a file and echo out every single line: Loading Loading @@ -47,7 +59,6 @@ done `$1` here represent the first argument. ```bash if [ "$1" == "" ]; then echo "This happens" fi Loading @@ -65,7 +76,6 @@ else fi ``` ## Command line arguments Command line arguments are represented like this Loading @@ -75,6 +85,7 @@ Command line arguments are represented like this $1 ``` This is the first command line argument. ## Daemonize an execution Loading @@ -89,7 +100,6 @@ for ip in $(cat ips.txt); do done ``` ## Use the output of command It has happened to me several times that I want to input the output of a command into a new command, for example: Loading @@ -111,3 +121,4 @@ cat $(locate 646.c | tail -n 1) ```