我想解析 mysources.list以提取存储库列表。我有:
## Some comment
deb http://some.vendor.com/ubuntu precise stable
deb-src http://some.vendor.com/ubuntu precise stable
deb http://some.othervendor.com/ubuntu precise experimental # my current favorite
Run Code Online (Sandbox Code Playgroud)
我想要:
http://some.vendor.com/ubuntu precise stable
http://some.othervendor.com/ubuntu precise experimental
Run Code Online (Sandbox Code Playgroud)
所以我需要: 只在行首到行尾或一个#字符带有“deb”的行,但不包括它。到目前为止,我有:
grep -o "^deb .*"
Run Code Online (Sandbox Code Playgroud)
但是如何在#不匹配 的情况下匹配或结束行#?