Affichage des articles dont le libellé est ksh. Afficher tous les articles
Affichage des articles dont le libellé est ksh. Afficher tous les articles

mercredi 19 décembre 2012

apply command (in AIX only?)

Here is a fast way to do function loop : 

apply "ssh server%1_pers date" 2 3 5 6  7 8

Replaces %1 with following parameters 

same as : 

for i in 2 3 5 6 7 8 
do
     ssh server${i}_pers date
done

Exclude files or directories from commands

An easy way to remove elements from command line : 

root:/# rm !(*.c|*.h)  => remove every files except *.c or *.h) 

another syntax : 

root:/# rm !(*.@(c|h))  => same thing ...

Can be used with grep, for directories exlusion. :

root:/#  grep P770_P7_1_A30 !(www|logs)/* => grep P770_P7_1_A30 from every underlying directories, except www and logs

mardi 6 mars 2012

Formatter la sortie en ksh

Pour avoir des chiffres sur 3 digits en shell, il suffit de formatter la variable via un typeset : 
let a=1
typeset -RZ3 variable
echo "a=$a"
 
a=001

mercredi 28 décembre 2011

sed -i doesn't work on AIX

To change a file on only one command  :

perl -p -i -e "s/iiii/uuu/" titi

mardi 27 septembre 2011

tips vi

passer des commandes shells directement dans le vi :

:1,$!awk '{ print $1 }


ou prendre en input chaque ligne et l’intégrer dans une commande :

:%!awk '{ system("host "$1)}'

mercredi 4 août 2010

removing end of a variable

export TOTO=fssam0sv
echo ${TOTO%%sv}

ca retire le sv de la fin de la variable

ksh tip

simple way to get input caracter in the output text :

cat $i | bla bla | awk '{ var " " bla bla bla $1" "$2 bla bla }' var=$i >> out

vendredi 17 avril 2009

nice awk tip !

- ex : to delete disks not belonging to rootvg :

lspv | grep -v rootvg|awk '{ print "rmdev -dl "$1 }'| ksh

Very useful to treat multiple lines commands in one line .... instead of the usual for i in ....