//View Tip #311
Similar Tips
» Bash
» Random line
» Check low space
» a better cut
» list the most recent files in a directory


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Tired to get your mailbox full of cron information messages?
Eg.: some programs (pg_dump, /etc/init.d/xxx, ...) output informational messages on stderr, but you can't close stderr because it may also contain failure informations.


LOG="/tmp/myscript-`date +%s`.tmp" IGNORE='^(Username: Password:|)[[:space:]]*$' # message to ignore, for demonstration only exec 3<&2; exec 2>$LOG # duplicate stderr for later use; redirect stderr to $LOG file
# insert your code (eg.: echo -e "login\npassword"|pg_dump -u user > file.dump)
exec 2<&3 # restore stderr # if $LOG file is not empty and contain anything else than what should be ignored, output it to stderr (for demonstration purpose) [ -s $LOG ] && egrep -vq $IGNORE $LOG && egrep -v $IGNORE $LOG >&2 rm -f $LOG

View Comments »


Add your comment

Comments are currently disabled
No Comments

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit