Re: [resolu] Bash et options de ligne de commande
Arnaud JAYET a écrit :
Bonjour,
en espérant pas etre HS vu que c'est plus une question programmation
Linux que purement Debian.
je souhaite ecrire un script bash utilisant des flags avec des noms
longs genre :
$ ./monscript --user=toto --group=tutu
Salut,
me répond à moi-meme, si cela peut servir à d'autres....
utiliser getopt -o <optstring> -l <opstring>
et puis lire, relire et re-relire le man ;-) car
man getopt
EXAMPLES
Example scripts for (ba)sh and (t)csh are provided with the
getopt(1) distribution, and are
optionally installed in /usr/lib/getopt or /usr/local/lib/getopt
(if you have created it).
juste que c'est pas dans /usr/lib/getopt mais dans
/usr/share-doc/util-linux/examples (paquet util-linux)
$ ls /usr/share/doc/util-linux/examples/
fstab.example2.gz getopt-parse.tcsh.gz getopt-test.tcsh.gz
getopt-parse.bash.gz getopt-test.bash.gz sfdisk.examples.gz
$ zcat getopt-parse.bash.gz
un beau script d'exemples , ouin.....
A+
Arnaud
Reply to: