Linux Application: July 2008 Archives

上次那篇Blog 用的send-hook是不对滴,应该用message-hook来搞。因为set from命令会永久改变from的值,因此每次判断之前要先reset到默认值然后再做判断。贴下我的配置:

message-hook '~A' "set from=detrox@mycompany.com"
message-hook '~f "(gmail|jianingy)\.com"' "set from=detrox@gmail.com"
message-hook '~t "(gmail|jianingy)\.com"' "set from=detrox@gmail.com"

msmtp本身是支持多个msmtp的。这些smtp的可以通过mutt的set from='xxx'来选取。因此,mutt能否使用多个smtp的问题就等价于是mutt能否根据不同情况改变from的值。事实上,mutt的send hook整好可以用来解决这个问题。请看我的mutt配置文件

set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname="Jianing Yang"
set envelope_from=yes
set from=mycompany@email.com

send-hook '~f detrox@gmail.com' 'set from=detrox@gmail.com'
send-hook '~t detrox@gmail.com' 'set from=detrox@gmail.com'
send-hook '~t [^@]+@jianingy.com' 'set from=detrox@gmail.com'

通过上面的配置,mutt在发送邮件时会根据如下条件改变from地址:

1.邮件来自detrox@gmail.com
2.邮件是发往detrox@gmail.com
3.邮件是发往@jianingy.com域的

用xargs加速grep

| | Comments (0) | TrackBacks (0)

xargs有个开关-P,意思是同时启动多少个子进程。借助xargs的这个特性可以加速grep文件的速度。例如,

grep  -r "libm.so.2" *

可以改写为

find . -type f | xargs -n 1 -P 20 grep "libm.so.2"

这样就会有20个进程同时查找了。

October 2008

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Friends

Archives

Powered by Movable Type