User Tools

Site Tools


scripting:sh

Bourne Shell

Loop through multi line text (including spaces)
while read LINE
do
    echo "${LINE}"
done <<< "`printf "line1\nline2"`"

or in bashish with command output:

while read LINE
do
    echo "${LINE}"
done <<< "$(ls -1)"
Calculations

awk

echo 3.14158 2.348 | awk '{ printf("%f\n", $1/$2) }' 
echo "" | awk '{ printf("%i\n", 10+5) }'
awk '{ print $1/2 }' <<< "5"

bc

echo "$charge_percent" | bc -l

bash

result=$((30*1000/60))
scripting/sh.txt · Last modified: 2016-05-20 17:00 by root