Howto bash
==========
# shebang
#!/bin/bash
# print text to console:
echo 'text'
# read variable from console:
read anweisung
# if statement:
if [ "$anweisung" = "2" ]; then
..
elseif
..
fi
if [ "$volume" -lt "2" ]; then
..
fi
if [ "$volume" -gt "2" ]; then
..
fi
# while-loop:
while true;do
..
done
# For loop
#!/bin/bash
for i in $( ls ); do
echo item: $i
done
# For loop with variable (works only in ksh)
#!/bin/ksh
t=5
n=1
for i in (1..$t); do
let 'n=n+1'
done
# For loop with variable
#!/bin/bash
t=5
n=1
for i in $(seq 1 $t); do
let 'n=n+1'
done
# initialize bash-script:
#!/bin/bash
# read file records.txt and print row wise:
while read p; do
echo $p
done <records.txt
# write text to file:
echo $p > copy.txt
# append test to file:
echo $p >> copy.txt
# clear history
history -c; hitory -w
# concatenate two strings
VAR1='Hello'
VAR2='World'
C=$VAR1" "$VAR2
echo $C
# wait for a process to finish
wait <PID>
# delay execution
sleep 5
sleep 1m 10s
# loop over files
https://www.cyberciti.biz/faq/bash-loop-over-file/
# escape character and line break
\
# compile
shc -f script.sh -o binary_name