####
sed '/cryincold/ p' text // Print lines match "cryincold"
sed '/cryincold/! p' text // Print lines do NOT match "cryincold", pay attention to theexclamatory mark !
####
An & which is a special character in sed & awk is replaced by the matched substring. /& put literal &.
####
sed 110q filename // print filename the first 110 lines
sed -n '10, 20p' filename // print lines between 10 and 20
####
sed /^[[:space:]]*$/d file_name // Erase all space line.
####
sed -n 's/.*/[/(.*/)/].*//1/p' filename // get all section names between [ and ]
本文介绍了一系列实用的SED命令示例,包括如何打印匹配特定字符串的行、删除空白行、提取文件中指定范围的行以及获取文件中特定格式的节名称等。通过这些实例,读者可以快速掌握SED命令的基础用法及其在文本处理中的强大功能。
994

被折叠的 条评论
为什么被折叠?



