Diferencia entre revisiones de «Bash»

De gacq wiki
Saltar a: navegación, buscar
(Sin diferencias)

Revisión del 15:36 27 jul 2006

Guias

* http://db.ilug-bom.org.in/Documentation/abs-guide/

loops

  for i in `/usr/bin/seq 1 10`
  do
    /bin/echo $i
  done

  for (( i=11; i<=20; i++ ))
  do
    /bin/echo $i
  done

Estructuras basicas

for i in $( ls ); do
   echo item: $i
done

         COUNTER=0
         while [  $COUNTER -lt 10 ]; do
             echo The counter is $COUNTER
             let COUNTER=COUNTER+1 
         done

         COUNTER=20
         until [  $COUNTER -lt 10 ]; do
             echo COUNTER $COUNTER
             let COUNTER-=1
         done

Functions

           #!/bin/bash 
           function quit {
               exit
           }
           function hello {
               echo Hello!
           }
           hello
           quit
           echo foo 

Functions with parameters

                #!/bin/bash 
                function quit {
                   exit
                }  
                function e {
                    echo $1 
                }  
                e Hello
                e World
                quit
                echo foo