4259 links
  • Arnaud's links
  • Home
  • RSS Feed
  • Tag cloud
  • Login
search: tag:indirection tag:stdin tag:crontab tag:vanish tag:rsync — newest first
  • Comment filtrer la sortie d'erreur (seulement)

    Prenons un bash qui ouput sur sa sortie standard (stdout) et sur sa sortie d'erreur (stderr) :

    cat test.bash

    echo good
    echo bad >&2
    echo vanish >&2
    echo good!

    Comment faire pour rediriger la sortie standard vers un fichier (ou /dev/null pour l'exemple) et filter la sortie d'erreur pour retirer la ligne "vanish" ?

    Pour ça il faut utiliser un process substitution :

    /root/test.bash 2> >(grep -v vanish >&2) >/dev/null

    Bien pratique dans un crontab pour recevoir un peu moins de mail lorsqu'on a des "erreurs" acceptables (rsync vanished par exemple)

    SHELL=/bin/bash
    * * * * * root /root/test.bash 2> >(grep -v vanish >&2) >/dev/null

    Pour en savoir plus sur les process substitution : http://tldp.org/LDP/abs/html/process-sub.html

    November 7, 2014 - permalink - https://links.infomee.fr/shaare/-D0dqQ
    cron crontab indirection redirection rsync stderr stdin vanish