User Tools

Site Tools


scripting:sh

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting:sh [2012-03-21 19:47] rootscripting:sh [2016-05-20 17:00] (current) root
Line 1: Line 1:
 ====== Bourne Shell ====== ====== Bourne Shell ======
  
-== Text zeilenweise verarbeiten ==+== Loop through multi line text (including spaces) ==
  
-<code> +<code bash
-while read LINE;+while read LINE
 do do
-        echo "${LINE}"+    echo "${LINE}"
 done <<< "`printf "line1\nline2"`" done <<< "`printf "line1\nline2"`"
 +</code>
 +
 +or in bashish with command output:
 +
 +<code bash>
 +while read LINE
 +do
 +    echo "${LINE}"
 +done <<< "$(ls -1)"
 </code> </code>
  
Line 13: Line 22:
  
 awk awk
-  echo 3.14158 2.348 | awk '{ printf("%f\n", $1/$2) }'  +<code bash> 
-  echo "" | awk '{ printf("%i\n", 10+5) }' +echo 3.14158 2.348 | awk '{ printf("%f\n", $1/$2) }'  
-  +echo "" | awk '{ printf("%i\n", 10+5) }' 
 +awk '{ print $1/2 }' <<< "5" 
 +</code> 
 bc bc
-  echo "$charge_percent" | bc -l +<code bash> 
- +echo "$charge_percent" | bc -l 
-bash (nicht portable, deshalb nicht zu empfehlen) +</code>
-  result=$((30*1000/60))+
  
 +bash
 +<code bash>
 +result=$((30*1000/60))
 +</code>
scripting/sh.1332355658.txt.gz · Last modified: 2014-12-18 20:10 (external edit)