Petr Hlobil - Osobní stránky jednoho informatika
PHP programátor, Linux administrátor, Tvorba webových stránek
- Nacházíte se zde:
- Linux
- Bash
Poslední články
Bash
http://www.ics.muni.cz/bulletin/articles/33.html - AWK manual
cat /etc/passwd | awk -F ':' '{sub(/web/,"test");print $2" "$1}'
cat /etc/passwd | awk -F ':' '{if($1~/web/){print $2" "$1}}'
cat /etc/passwd | awk -F ':' '{if(1==1){print $2" "$1}}'
ps -a | awk '{$1=1+15;print $2","$1}'
cat /etc/passwd | awk '{for($1=1;$1<10;$1++)print $1}'
ps -av | cut -d ' ' -f 2,3
for i in `ps -av | cut -d ' ' -f 2`;do echo 'test: '$i;done;
for test in {1..10};do echo 'test: '$test;done;
i=1; while [ $i -lt 10 ]; do echo $i; i=`expr $i + 1`; done;
count=0;for i in `cat /etc/passwd | awk -F ':' '{if($1~/web/)print $1}'`; do count=`expr $count + 1`; done; echo $count;
count=0;for i in `cat /etc/passwd | awk -F ':' '{if($1!~/web/)print $1}'`; do count=`expr $count + 1`; done; echo $count;
REGULAR EXPRESSION
cat /etc/passwd | awk -F ':' '{if($1~/^web1$/)print $1}'
for i in `cat /etc/passwd | awk -F ':' '{print $1}'`; do if [ ! -d /home/$i ]; then echo $i; fi; done;
//ukazka 1
ret="";
for i in `cat /etc/passwd | awk -F ':' '{print $1}'`;
do
if [ -z $ret ];
then delim="";
else delim=",";
fi;
ret=$ret$delim$i;
done;
echo $ret;