Gerd-Christian Michalke wrote:

Bonjour,

une petite question de script bash/sed/awk

Admettons que je veuille remplacer une cha�ne de caract�re par un nombre al�atoire et cette cha�ne. J'ai essay�

cat fichier | sed -e "s/.*\(CHAINE\).*/${RANDOM}-\1/g"

Fort logiquement, sed va appeler une fois la variable RANDOM, ce qui fait que j'obtiendrai

nnnnnnnnn-CHAINE
nnnnnnnnn-CHAINE
nnnnnnnnn-CHAINE

et ainsi de suite. Ce n'est pas ce que je veux: pour bien faire, il faudrait qu'un nouveau nombre soit g�n�r� � chaque fois que sed trouve une occurrence de la cha�ne. Il y a peut-�tre moyen de faire qqc avec awk, mais je ne connais pas assez ;-(

Toute id�e est la bienvenue !

Merci � l'avance,
Gerd

_______________________________________________________
Linux Mailing List - http://www.unixtech.be
Subscribe/Unsubscribe: http://www.unixtech.be/mailman/listinfo/linux
Archives: http://www.mail-archive.com/[EMAIL PROTECTED]
IRC: chat.unixtech.be:6667 - #unixtech




Il y a /dev/random : j'y pompe par ex 10 bytes :

dd if=/dev/random bs=10 count=1 | od -bc

(juste essay�, jamais utilis�)

   Alain

--
------------------------------------------------------------
Dr Alain EMPAIN <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Bioinformatics, Molecular Genetics, Fac. Med. Vet., University of Li�ge, Belgium
Bd de Colonster, B43 B-4000 Li�ge (Sart-Tilman)
WORK: +32 4 366 3821 FAX: +32 4 366 4122
HOME: rue des Martyrs,7 B- 4550 Nandrin +32 85 51 23 41 GSM: +32 497 70 17 64
--------------------------------------------------------------------------------
"I worry about my child and the Internet all the time, even though she's
too young to have logged on yet. Here's what I worry about. I worry that
10 or 15 years from now, she will come to me and say 'Daddy, where were
you when they took freedom of the press away from the Internet?'" --Mike Godwin, Electronic Frontier Foundation --------------------------------------------------------------------------------


_______________________________________________________
Linux Mailing List - http://www.unixtech.be
Subscribe/Unsubscribe: http://www.unixtech.be/mailman/listinfo/linux
Archives: http://www.mail-archive.com/[EMAIL PROTECTED]
IRC: chat.unixtech.be:6667 - #unixtech

Répondre à