Outils pour utilisateurs

Outils du site


informatique:liste_man.sh

Script "liste_man.sh"

Ce script a pour objet de générer un fichier .txt contenant le man des commandes qui sont dans ce wiki.

Avec deux commandes

Voici un exemple avec seulement deux commandes :

#!/bin/bash
 
# Déclaration d'un tableau contenant la liste des commandes dont on veut générer le man
tab=("cat" "cd")
 
# Afficher tous les éléments de "tableau"
echo ${tab[@]}
 
# Exporter le man de chaque commande
for i in ${!tab[@]}
do
        echo -e "==== Manuel de la commande \"${tab[i]}\" ====\n\n<code>" > man_de_${tab[i]}.txt
        man ${tab[i]} >> man_de_${tab[i]}.txt
        echo -e "\n</code >" >> man_de_${tab[i]}.txt
done
 
exit 0

Attention, j'ai rajouté un espace à la balise “/code” dans le script, pour éviter les conflits avec les balises du wiki.

On lance le script pour vérifier son bon fonctionnement :

$ ls
liste_man.sh
$ ./liste_man.sh 
cat ls
$ ls
liste_man.sh  man_cat.txt  man_ls.txt
$ head man_de_cat.txt 
==== Manuel de la commande "cat" ====

<code>
CAT(1)                                                         Commandes                                                         CAT(1)

NOM
       cat - Concaténer des fichiers et les afficher sur la sortie standard

Pour pouvoir exécuter le script avec le raccourcis ./, il ne faut pas oublier de faire $ chmod +x liste_man.sh

Script avec toutes les commandes

#!/bin/bash
 
# Déclaration du tableau contenant la liste des commandes
tab=("apt" "aptitude" "awk" "bash" "cat" "chgrp" "chmod" "chown" "cmake" "cp" 
"crontab" "curl" "cut" "date" "dd" "diff" "diff3" "dig" "dir" "dirname" "dmesg" 
"dpkg" "egrep" "emacs" "file" "find" "free" "from" "fsck" "git" "gksudo" "gpg" 
"gpg2" "grep" "gunzip" "gzip" "head" "hexdump" "history" "host" "hostname" 
"htop" "htpasswd" "ifconfig" "ifdown" "ifup" "ip" "iptables" "irssi" "isodump" "journalctl" 
"kill" "kvm" "last" "latex" "less" "line" "link" "locate" "logname" "ls" "lscpu" "lshw" "lsof" 
"lspci" "lsusb" "lynx" "mail" "make" "man" "minicom" "mlocate" "modprobe" "mogrify" 
"more" "most" "mount" "mutt" "nano" "nc" "ncat" "netcat" "nl" "nmap" "nohup" 
"nslookup" "open" "openssl" "pager" "pdfinfo" "pdflatex" "pftp" "photorec" 
"pico" "print" "proxy" "ps" "pulseaudio" "pwd" "python" "qpdf" "quickbook" 
"ranger" "rename" "resize" "rm" "rmdir" "route" "rsync" "rvim" "scp" 
"screendump" "script" "sdiff" "seahorse" "sed" "see" "sftp" "size" "sleep" 
"snice" "sort" "split" "ssh" "sshfs" "startx" "su" "sudo" "systemd" "tail" "tar" "tee" 
"telnet" "top" "touch" "tracepath" "tree" "umount" "unar" "uncompress" "uniq" 
"unrar" "until" "unzip" "uptime" "users" "vi" "vim" "volname" "w" "wait" "wc" "weave" 
"wget" "whatis" "whereis" "which" "whiptail" "who" "whoami" "whois" "wish" 
"write" "xrandr" "yes" "ypdomainname" "zcat" "zcmp" "zip")
 
# Afficher tous les éléments de "tableau"
echo ${tab[@]}
 
# Exporter le man de chaque commande
for i in ${!tab[@]} 
do 
	echo -e "==== Manuel de la commande \"${tab[i]}\" ====\n\n<code>" > man_de_${tab[i]}.txt
	man ${tab[i]} >> man_de_${tab[i]}.txt
	echo -e "\n</code >" >> man_de_${tab[i]}.txt
done
 
exit 0
Exécution
simon@debian8:~/site/pages-de-man$ ls
liste_command.sh  liste_man.sh
simon@debian8:~/site/pages-de-man$ ./liste_man.sh 
apt aptitude awk bash cat chgrp chmod chown cmake cp crontab curl cut date dd diff diff3 dig dir dirname dmesg dpkg egrep emacs file find free from fsck git gksudo gpg gpg2 grep gunzip gzip head hexdump history host hostname htop htpasswd ifconfig ifdown ifup ip iptables irssi isodump journalctl kill kvm last latex less line link locate logname ls lscpu lshw lsof lspci lsusb lynx mail make man minicom mlocate modprobe mogrify more most mount mutt nano nc ncat netcat nl nmap nohup nslookup open openssl pager pdfinfo pdflatex pftp photorec pico print proxy ps pulseaudio pwd python qpdf quickbook ranger rename resize rm rmdir route rsync rvim scp screendump script sdiff seahorse sed see sftp size sleep snice sort split ssh sshfs startx su sudo systemd tail tar tee telnet top touch tracepath tree umount unar uncompress uniq unrar until unzip uptime users vi vim volname w wait wc weave wget whatis whereis which whiptail who whoami whois wish write xrandr yes ypdomainname zcat zcmp zip
man: impossible d'ouvrir /usr/share/man/man3/caca_event_@0.3caca: Aucun fichier ou dossier de ce type
mdoc warning: Empty input line #226
mdoc warning: Empty input line #228
mdoc warning: Empty input line #251
mdoc warning: Empty input line #253
mdoc warning: Empty input line #255
mdoc warning: Empty input line #482
mdoc warning: Empty input line #484
mdoc warning: Empty input line #547
Aucune entrée de manuel pour until
man: impossible d'ouvrir /usr/share/man/man3/caca_event_@0_@2.3caca: Aucun fichier ou dossier de ce type
simon@debian8:~/site/pages-de-man$ ls
liste_command.sh     man_de_from.txt        man_de_line.txt      man_de_nslookup.txt    man_de_seahorse.txt    man_de_unzip.txt
liste_man.sh         man_de_fsck.txt        man_de_link.txt      man_de_openssl.txt     man_de_sed.txt         man_de_uptime.txt
man_de_aptitude.txt  man_de_git.txt         man_de_locate.txt    man_de_open.txt        man_de_see.txt         man_de_users.txt
man_de_apt.txt       man_de_gksudo.txt      man_de_logname.txt   man_de_pager.txt       man_de_sftp.txt        man_de_vim.txt
man_de_awk.txt       man_de_gpg2.txt        man_de_lscpu.txt     man_de_pdfinfo.txt     man_de_size.txt        man_de_vi.txt
man_de_bash.txt      man_de_gpg.txt         man_de_lshw.txt      man_de_pdflatex.txt    man_de_sleep.txt       man_de_volname.txt
man_de_cat.txt       man_de_grep.txt        man_de_lsof.txt      man_de_pftp.txt        man_de_snice.txt       man_de_wait.txt
man_de_chgrp.txt     man_de_gunzip.txt      man_de_lspci.txt     man_de_photorec.txt    man_de_sort.txt        man_de_wc.txt
man_de_chmod.txt     man_de_gzip.txt        man_de_ls.txt        man_de_pico.txt        man_de_split.txt       man_de_weave.txt
man_de_chown.txt     man_de_head.txt        man_de_lsusb.txt     man_de_print.txt       man_de_sshfs.txt       man_de_wget.txt
man_de_cmake.txt     man_de_hexdump.txt     man_de_lynx.txt      man_de_proxy.txt       man_de_ssh.txt         man_de_whatis.txt
man_de_cp.txt        man_de_history.txt     man_de_mail.txt      man_de_ps.txt          man_de_startx.txt      man_de_whereis.txt
man_de_crontab.txt   man_de_hostname.txt    man_de_make.txt      man_de_pulseaudio.txt  man_de_sudo.txt        man_de_which.txt
man_de_curl.txt      man_de_host.txt        man_de_man.txt       man_de_pwd.txt         man_de_su.txt          man_de_whiptail.txt
man_de_cut.txt       man_de_htop.txt        man_de_minicom.txt   man_de_python.txt      man_de_systemd.txt     man_de_whoami.txt
man_de_date.txt      man_de_htpasswd.txt    man_de_mlocate.txt   man_de_qpdf.txt        man_de_tail.txt        man_de_whois.txt
man_de_dd.txt        man_de_ifconfig.txt    man_de_modprobe.txt  man_de_quickbook.txt   man_de_tar.txt         man_de_who.txt
man_de_diff3.txt     man_de_ifdown.txt      man_de_mogrify.txt   man_de_ranger.txt      man_de_tee.txt         man_de_wish.txt
man_de_diff.txt      man_de_ifup.txt        man_de_more.txt      man_de_rename.txt      man_de_telnet.txt      man_de_write.txt
man_de_dig.txt       man_de_iptables.txt    man_de_most.txt      man_de_resize.txt      man_de_top.txt         man_de_w.txt
man_de_dirname.txt   man_de_ip.txt          man_de_mount.txt     man_de_rmdir.txt       man_de_touch.txt       man_de_xrandr.txt
man_de_dir.txt       man_de_irssi.txt       man_de_mutt.txt      man_de_rm.txt          man_de_tracepath.txt   man_de_yes.txt
man_de_dmesg.txt     man_de_isodump.txt     man_de_nano.txt      man_de_route.txt       man_de_tree.txt        man_de_ypdomainname.txt
man_de_dpkg.txt      man_de_journalctl.txt  man_de_ncat.txt      man_de_rsync.txt       man_de_umount.txt      man_de_zcat.txt
man_de_egrep.txt     man_de_kill.txt        man_de_nc.txt        man_de_rvim.txt        man_de_unar.txt        man_de_zcmp.txt
man_de_emacs.txt     man_de_kvm.txt         man_de_netcat.txt    man_de_scp.txt         man_de_uncompress.txt  man_de_zip.txt
man_de_file.txt      man_de_last.txt        man_de_nl.txt        man_de_screendump.txt  man_de_uniq.txt
man_de_find.txt      man_de_latex.txt       man_de_nmap.txt      man_de_script.txt      man_de_unrar.txt
man_de_free.txt      man_de_less.txt        man_de_nohup.txt     man_de_sdiff.txt       man_de_until.txt

Je ne sais pas exactement d'où viennent les erreurs à l'exécution…

informatique/liste_man.sh.txt · Dernière modification : 2020/08/09 13:03 de 127.0.0.1