====== Mémo BASH ====== osd_cat -s 4 -l 20 -p top -A center -c blue --delay=2 -f "-*-courier-*-r-*-*-*-600-*-*-*-*-*" ip.php htpasswd -nb -m test1 toto1 |head -1 >> fichier_htpasswd Pour trouver les dokuwikis hébergés sur une machine : find -name doku.php Pour donner la taille uniquement des dossiers et non de chaque fichier et/ou sous-dossiers et les trier : du -h --max-depth=1 | sort -rn Pour déplacer les fichiers de plus de 3 ans : find ftp/ -type f -a -mtime +1095 -exec mv {} /mnt/serveur/disque01/.recycle/anciens_3ans/ \; Freenas pour trouver les fichiers *.txt : find -L /mon_sous-dossier/ -type f -name "*.txt" > chemins.txt #!/bin/sh # Un exemple de boucle : while [ 1 ]; do echo "$(date +%H%M%S)" echo "$(gmirror status | grep mirror/serveur)" sleep 30 done #!/bin/sh # Un exemple de boucle : grepc="$(cat .grsync/default.log | grep -c "fin-gm-grsync-2015-05.php")" # while [ 1 ]; while [ "$grepc" -ne "1" ]; do echo "$(date +%H%M%S)" sh scripts/grepc.sh sleep 10 done echo "Grepc = 1 OK" echo $grepc exit 0 #!/bin/sh # Un exemple de boucle avec capture : visualisateur=mirage while [ 1 ]; do echo "$(date +%H%M%S)" echo -n "Capture dans " echo -n "5 " sleep 1 echo -n "4 " sleep 1 echo -n "3 " sleep 1 echo -n "2 " sleep 1 echo "1 " rm -fr /tmp/*.png xfce4-screenshooter -f -o $visualisateur sleep 15 echo -n "Fermeture de $visualisateur dans " echo -n "5 " sleep 1 echo -n "4 " sleep 1 echo -n "3 " sleep 1 echo -n "2 " sleep 1 echo "1 " killall $visualisateur sleep 95 done #!/bin/bash grepc="$(md5sum -c MD5SUM | grep -c FAILED)" if [ $grepc = "1" ] then echo "Grepc = 1 FAILED" echo $grepc else echo "Grepc = 0 OK" echo $grepc fi cut -c 16-30 ping -c 4 192.168.179.1 && ping -c 4 10.0.1.1 && ping -c 4 195.6.68.2 && ping -c 4 free.fr && sleep 10 && clear date +%Y%m%d-%H%M%S jhead -n%Y-%m-%d-%H-%M-%S *.jpg sudo nano /usr/share/applications/debian-xterm.desktop [Desktop Entry] Name=XTerm Comment=standard terminal emulator for the X window system Exec=xterm Terminal=false Type=Application Encoding=UTF-8 Icon=xterm-color_48x48 Categories=System;TerminalEmulator; X-Desktop-File-Install-Version=0.20 xterm -geometry 238x64 mkdir imgs && find -name "*.jpg" -type f -exec cp {} imgs \; ifconfig -a eth0 | grep "inet " | cut -d : -f2 | cut -d B -f1 #!/bin/sh # Un exemple de boucle eth0 : while [ 1 ]; do echo "---" echo "$(date +%H%M%S)" ifconfig -a eth0 | grep "inet " | cut -d : -f2 | cut -d B -f1 echo "---" sleep 5 echo "---" echo "$(date +%H%M%S)" ifconfig -a eth0 | grep "inet " | cut -d : -f2 | cut -d B -f1 echo "---" sleep 5 clear done tail -n 10 .grsync/default.log && echo " " && df /media/sde1/ | tail -n 1 | cut -c 31-40 /sbin/ifconfig | /bin/grep "Bcast:" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1 /sbin/ip -f inet -o addr show eth0 | cut -d\ -f 7 | cut -d/ -f 1 find . -type d -exec chmod 705 {} \; find . -type f -exec chmod 604 {} \; cat /var/log/clonezilla.log | grep -c boot