13.3 Awk
R�f�rences pour Awk :
-
Effective awk Programming, 3rd edition (O'Reilly)
-
Sed & awk, 2nd edition (O'Reilly)
-
mawk(1)
et gawk(1)
-
info gawk
Court exemple de programme (cr�e des entr�es de compte pour
newusers
) :
#!/usr/bin/awk -f
# Script pour cr�er un fichier utilisable avec la commande 'newusers'
# � partir d'un fichier contenant des IDs utilisateur et des mots de
# passe sous la forme :
# Pr�nom Nom Mot_de_passe
# Copyright (c) KMSelf Sat Aug 25 20:47:38 PDT 2001
# Distributed under GNU GPL v 2, or at your option, any later version.
# This program is distributed WITHOUT ANY WARRANTY.
BEGIN {
# Assign starting UID, GID
if ( ARGC > 2 ) {
startuid = ARGV[1]
delete ARGV[1]
}
else {
printf( "Usage: newusers startUID file\n" \
"...where startUID is the starting userid " \
"to add, and file is \n" \
"an input file in form firstname last name password\n" \
)
exit
}
infile = ARGV[1]
printf( "Starting UID: %s\n\n", startuid )
}
/^#/ { next }
{
++record
first = $1
last = $2
passwd = $3
user= substr( tolower( first ), 1, 1 ) tolower( last )
uid = startuid + record - 1
gid = uid
printf( "%s:%s:%d:%d:%s %s,,/home/%s:/bin/bash\n", \
user, passwd, uid, gid, first, last, user \
)
}
Deux paquets fournissent un awk
POSIX dans Debian :