How can I include a line until # but without the # when parsing 'sources.list' with regex?
- by stwissel
I want to parse my sources.list to extract the list of repositories. I have:
## 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
I want:
http://some.vendor.com/ubuntu precise stable
http://some.othervendor.com/ubuntu precise experimental
So I need: only lines with deb at the beginning and until the end of the line or a # character but excluding it.
So far I have:
grep -o "^deb .*"
But how to match # or LineEnd and excluding the #?