[Bash] Trier par ordre alphanumérique dans un fichier de sortie
Bonjour,
Je rencontre un petit soucis pour le résultat d'un audit que je dois faire.
Je dois récupérer la non existance de certains fichiers à remettre aux normes dans différents conteneurs.
Mon soucis est que je n'arrive pas à trier le fichier de sortie comme je le voudrais malgrer les différentes méthodes testés avec sortJ'ai essayé sans succès le -V ou -k3k,3VJ'ai en retour sort: multi-character tab `-V' sort: multi-character tab `-k3k,3V'Je suis certains de mal placé mon sort (très longtemps que je l'ai utilisé dans un script étant passer un peu au python pour ma mission actuelle)
Voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| #!/bin/bash
#set -x
##Récupération de tous les Home utilisateurs (différencier zinc, jaspe, jade) qui ont un bash (grep -v nologin ou false)
CONTE=$1
LOGIN=$(getent passwd | egrep -v '(nologin|false|root|sync|shutdown|halt|nagios|copykey|nbackup|exploit|exploi4c|compta)' $CONTE | awk -F ":" '{print $1}')
CONT=$(getent passwd $LOGIN|cut -d/ -f3)
#log
LOGbash=/ccc/common/exploit/script_en_test/IBL/log
LOGbash2=/ccc/common/exploit/script_en_test/IBL/log
LOGbash3=/ccc/common/exploit/script_en_test/IBL/log
> $LOGbash/RC_absent.log
> $LOGbash2/Profile_absent.log
> $LOGbash3/Profile_RC_absent.log
for USER in $LOGIN
do
#echo $USER
CONT=$(getent passwd $USER|cut -d/ -f3)
GRP_PRINC=`id -gn $USER`
if [ "$CONT" = "cont005" ]
then
HOM="/ccc/dsk/jasper/vohcalc1/${CONT}_user/$GRP_PRINC/$USER"
elif [ "$CONT" = "cont000" ]
then
if [ $(echo "$USER" | grep ".*4c$") ]
then
HOM="/ccc/dsk/zinc/home/$CONT/$USER"
elif [ $(echo "$USER" | grep ".*4t$") ]
then
HOM="/ccc/dsk/jasper/volhcalc1/${CONT}_user/$GRP_PRINC/$USER"
else
HOM="/ccc/cont000/dsk/jedi/home/user/$GRP_PRINC/$USER"
fi
elif [ "$CONT" = "cont999" ]
then
HOM="/ccc/dsk/jasper/vohcalc1/${CONT}_user/$GRP_PRINC/$USER"
else
HOM="/ccc/dsk/zinc/home/$CONT/$GRP_PRINC/$USER"
fi
#if [ $? -ne 0 ]
if [ ! -f $HOM/.bashrc ]
then
echo $USER $GRP_PRINC $CONT >> $LOGbash/RC_absent.log
elif [ ! -f $HOM/.bash_profile ]
then
echo $USER $GRP_PRINC $CONT | sort -t -V >> $LOGbash2/Profile_absent.log
elif [ ! -f $HOM/.bash_profile ] && [ ! -f $HOM/.bashrc ]
then
echo "RC et PROFILE absent pour $USER"
echo $USER $GRP_PRINC $CONT >> $LOGbash3/Profile_RC_absent.log
fi
done |
Ma sortie actuelle est du genre:
Code:
1 2 3 4 5
| xtoto ll2089 cont005
ytutu mn9064 cont003
ztete mms cont003
ptiti jo9065 cont003
cwiki pap2112 cont005 |
Et je souhaite la trier ainsi cont000 cont0001....