shell也玩段注释

1428阅读 0评论2008-11-16 ubuntuer
分类:

shell注释是#大家都知道,就像c的//,可是c的/**/可以实现段注释,shell怎么办到呢??

shell注释段
    :<<BLOCK
    ...
    segment
    ...
    BLOCK

cat date.sh
#!/bin/bash

#usage:yyyymmdd

(($#!=1))||((${#1}!=8)) && { echo "Usage:yyyymmdd";exit 1; }

year=${1:0:4}
month=${1:4:2}
day=${1:6:2}
(cal $month $year|grep -q "$day" && echo ok || echo error) 2>/dev/null

#plus

:<<BLOCK
ubuntu
debian
centos
fedora
redhat
BLOCK

下面是shell高人netman的一点小PS:    
    : << 'BLOCK' 還可以將裡面的變量擴展關