Shell tricks

Redirect out and err to file and output

strace -f program   2>&1 | tee -a ./stdeo

Get main script run directory

ROOT=$(dirname `readlink -f "$0"`)

Foreach splitted string

# items by space
UNITS="string splitted string"
for unit in ${UNITS[@]}
do
    echo $unit
done
# item by comma or other custom separator
UNITS="comma_split,ted_str,ings"
for unit in ${UNITS//,/ }
do
    echo $unit
done

TODO

concaterate agruments, heredoc modes, process by lines, wrap output of group of processes

Helper script prototype

Linuxengineering Toolbox helper script