Diferencia entre revisiones de «Bash»
De gacq wiki
| Línea 61: | Línea 61: | ||
quit | quit | ||
echo foo | echo foo | ||
| + | </nowiki></pre> | ||
| + | |||
| + | |||
| + | = Alias = | ||
| + | |||
| + | <pre><nowiki> | ||
| + | # busca archivos recursivamente por los directorios por contenido | ||
| + | alias ff='find . -type f | xargs grep $@' | ||
| + | # busca procesos segun un string | ||
| + | alias psg='ps -ef | grep -v grep | grep $@' | ||
</nowiki></pre> | </nowiki></pre> | ||
Revisión del 17:09 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
Alias
# busca archivos recursivamente por los directorios por contenido alias ff='find . -type f | xargs grep $@' # busca procesos segun un string alias psg='ps -ef | grep -v grep | grep $@'