2
回答
sed 命令的不解之处,求解释!
华为云数据库免费试用   

例子 A-12. behead: 去掉信件与新消息的头

#! /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'
	# --> 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
		sed -e '1,/^$/d' -e '/^[ 	]*$/d' $i  
            ###后面的 '/^[       ]*$/d' 是什么意思啊,久看不能理解啊,感觉和
            ###这例子自己的注释没什么关系 
		# --> 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
举报
皮皮大仙
发帖于6年前 2回/254阅
顶部