Shell脚本中的引号

为了方便使用各类Shell函数模板,于是写了一个简单的bash脚本:
#!/bin/bash

smail ()
{
    mail -s "$1" $2 <<_EOF
        $3
        Curr Time: `date "+%Y/%m/%d %T"`
_EOF
}
这样调用起来非常方便,只需:
smail "your mail title" perl6@127.com "your content"
但是如果要抄送给某个用户呢?由于$2是不能够加引用的,且地址最好使用变量来代替,这样变量也必须再次引用,这个与传统解释性语言不同的地方,变量需要再次引用才能传递,例子如下:
mailto="-c perl6@126.com perl6@127.com"
smail "your mail title" "$mailto" "your content
and more text"
只要有引号,还可以折行哟!

Monthly Archives

Pages

Powered by Movable Type 7.7.2

About this Entry

This page contains a single entry by Cnangel published on February 13, 2008 11:41 AM.

莫名其妙的pulse audio was the previous entry in this blog.

太帅了,3D is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.