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
Last revisionBoth sides next revision
scripting:sh [2013-11-22 11:05] rootscripting:sh [2016-01-10 21:29] root
Line 1: Line 1:
 ====== Bourne Shell ====== ====== Bourne Shell ======
  
-== Text zeilenweise verarbeiten ==+== Loop through multi line text (including spaces) ==
  
 <code> <code>
 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>
 +while read LINE
 +do
 +    echo "${LINE}"
 +done <<< "$(ls -1)"
 </code> </code>
  
Line 15: Line 24:
   echo 3.14158 2.348 | awk '{ printf("%f\n", $1/$2) }'    echo 3.14158 2.348 | awk '{ printf("%f\n", $1/$2) }' 
   echo "" | awk '{ printf("%i\n", 10+5) }'   echo "" | awk '{ printf("%i\n", 10+5) }'
 +  awk '{ print $1/2 }' <<< "5"
      
 bc bc
Line 21: Line 31:
 bash bash
   result=$((30*1000/60))   result=$((30*1000/60))
- 
scripting/sh.txt · Last modified: 2016-05-20 17:00 by root