User Tools

Site Tools


scripting:sh

This is an old revision of the document!


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.1452457746.txt.gz · Last modified: 2016-01-10 21:29 by root