Sed 赛程从赛后第一线开始,到第二场比赛结束
我有一个包含多个类似部分的文件Sed 赛程从赛后第一线开始,到第二场比赛结束,sed,range,Sed,Range,我有一个包含多个类似部分的文件 ... # PostgreSQL configuration example #production: # adapter: postgresql # database: redmine # host: localhost # username: postgres # password: "postgres" # SQLite3 configuration example #production: # adapter: sqlite3 # data
...
# PostgreSQL configuration example
#production:
# adapter: postgresql
# database: redmine
# host: localhost
# username: postgres
# password: "postgres"
# SQLite3 configuration example
#production:
# adapter: sqlite3
# database: db/redmine.sqlite3
# SQL Server configuration example
#production:
# adapter: sqlserver
# database: redmine
# host: localhost
# username: jenkins
# password: jenkins
...
我想评论/删除整个部分
对于SQLite3,我希望有以下输出:
...
# PostgreSQL configuration example
#production:
# adapter: postgresql
# database: redmine
# host: localhost
# username: postgres
# password: "postgres"
# SQLite3 configuration example
production:
adapter: sqlite3
database: db/redmine.sqlite3
# SQL Server configuration example
#production:
# adapter: sqlserver
# database: redmine
# host: localhost
# username: jenkins
# password: jenkins
...
我试过这样的方法:
sed -i -e '/SQLite3/+1,/^\s*$/ s/^#//' FILE
。。。但它不起作用,因为“+1”无效
比赛结束后,我如何在线路上开始一段距离?
我尝试了几个大括号和“n”的变体,但没有找到正确的拼写选择完整的范围,然后仅将替换命令应用于与第一个模式不匹配的行的子范围:
sed '/SQLite3/,/^$/ { /SQLite3/! s/^#// }' file
为了可读性而扩展:
sed '/SQLite3/,/^$/ {
/SQLite3/! {
s/^#//
}
}' file
请将该示例输入的所需输出添加到您的问题中。可能重复。。。修改此表单sed-n'/PAT1/,/PAT2/{/PAT1/!p}'file@Cyrus:更新。