Commands tagged mail (33)

  • This can be used to delete or archive old mails. In fact, for archiving its a bit different, you need to archive mails with any tools (e.g archivemail), and then deleting (if you want!). Here we use -path ".*/cur/*" to avoid files limit in bash globbing and to search in any inbox (e.g .mymail .spam .whatever). ! -newermt "1 week ago" can be read: All files which is older than "1 week ago", adapt it in consequence. Show Sample Output

    find . -path ".*/cur/*" -type f ! -newermt "1 week ago" -delete
    evolix · 2012-03-05 15:48:21 0
  • Counts of messages by recipient, with frozen messages excluded. Show Sample Output

    sudo /usr/sbin/exim -bp | sed -n '/\*\*\* frozen \*\*\*/,+1!p' | awk '{print $1}' | tr -d [:blank:] | grep @ | sort | uniq -c | sort -n
    blueskin · 2013-06-04 10:49:14 0
  • Poor email reputation got you down? Perhaps you're unknowingly forwarding every spam email that makes it through to to This command outputs every forwarding address set up within a Zimbra installation.

    for i in `zmprov -l gaa | cut -f2 -d"@" | uniq -c | awk '{print$2}'`; do zmprov -l gaa -v $i | grep -i zimbraPrefMailForwardingAddress; done
    skylineservers · 2014-11-17 15:24:46 0
  • I had to reconfigure all of my 150 domains to use "localhost" as IMAP/SMTP server instead of mail.[domain]. This little thing did the job in a fraction of a second!

    sed -i -E 's/mail\..*/localhost\"/g' *
    Blagus · 2016-01-15 14:48:32 0
  • This will send the web page at $u to . To send the web page to oneself, can be replaced by $(whoami) . The "charset" is UTF-8 here, but any alternative charset of your choice would work. `wget -O - -o /dev/null $u` may be considered instead of `curl $u` . On some systems the complete path to sendmail may be necessary, for instance /sys/pkg/libexec/sendmail/sendmail for some NetBSD.

    { u=""; echo "Subject: $u"; echo "Mime-Version: 1.0"; echo -e "Content-Type: text/html; charset=utf-8\n\n"; curl $u ; } | sendmail
    pascalv · 2010-02-24 04:18:30 1
  • Used it on daily basis, not sure if it's any better than the OPs version, tho' One advantage is - you can replace 'bash' at the end of the line with eg. cat - to check if the generated command is OK. Show Sample Output

    mailq |awk '/MAILER-DAEMON/{gsub("*","");printf("postsuper -d %s\n",$1)}'|bash
    unefunge · 2010-11-24 11:42:54 0

  • -1
    recoll -t -q "keyword" | grep message/rfc822 | sed -s 's,^.*\('$MAILDIR'[^]]*\)\].*$,\"\1\",' | xargs ln -sft $MAILDIR/bingo/cur/
    s5unty · 2011-12-09 17:22:51 0
  • It's not a big line, and it *may not* work for everybody, I guess it depends on the detail of access_log configuration in your httpd.conf. I use it as a prerotate command for logrotate in httpd section so it executes before access_log rotation, everyday at midnight.

    cat /var/log/httpd/access_log | grep q= | awk '{print $11}' | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1 | mail -s "[your-site] search strings for `date`"
    isma · 2009-11-22 03:03:06 3
  •  < 1 2

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Print a horizontal line

Perl one-liner to determine number of days since the Unix epoch
There are some environments that use this value for password and account expiration. It's helpful to be able to quickly determine the number of days since the Unix epoch (dse) when working directly with the configuration files as an administrator.

list directories only

Transform a portrait pdf in a landscape one with 2 pages per page
This is an example of the usage of pdfnup (you can find it in the 'pdfjam' package). With this command you can save ink/toner and paper (and thus trees!) when you print a pdf. This tools are very configurable, and you can make also 2x2, 3x2, 2x3 layouts, and more (the limit is your fantasy and the resolution of the printer :-) You must have installed pdfjam, pdflatex, and the LaTeX pdfpages package in your box.

Send your svn diff to meld
If you like to view what has been changed between revision 100 and the BASE on FILE. Meld will give you a nice overview.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

reduce mp3 bitrate (and size, of course)
Useful if you have to put some mp3 files into mobile devices (ie mobile phones with no much memory)

Create a new file

history autocompletion with arrow keys
This will enable the possibility to navigate in the history of the command you type with the arrow keys, example "na" and the arrow will give all command starting by na in the history.You can add these lines to your .bashrc (without &&) to use that in your default terminal.

Synchronise a file from a remote server
You will be prompted for a password unless you have your public keys set-up.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: