发表于 : 2007-05-10 23:06
ztf 写了:#! /bin/sh
# Strips off the header from a mail/News message i.e. till the first
# empty line
# Mark Moraes, University of Toronto
# ==> These comments added by author of this document.
if [ $# -eq 0 ]; then
# ==> If no command line args present, then works on file redirected to stdin.
sed -e '1,/^$/d' -e '/^[ ]*$/d' #空行的正则表达式^$,全空格行的表达式^[ ]*$,合起来就是删除没有类容的行,但这个sed似乎有问题,没有操作对象
# --> Delete empty lines and all lines until
# --> first one beginning with white space.
else
# ==> If command line args present, then work on files named.,
for i do #这个语法应该是错误的,.do前面应该有;
sed -e '1,/^$/d' -e '/^[ ]*$/d' $i #这个也是正则跟上面的一样,但这个是正确的,有操作对象
# --> Ditto, as above.
done
fi
# ==> Exercise: Add error checking and other options.
# ==>
# ==> Note that the small sed script repeats, except for the arg passed.
# ==> Does it make sense to embed it in a function? Why or why not?
请好心人解析一下sed的那两行