Phillip Wood [off-list ref] writes:
quoted
quoted
The trailing ".*" when matching commented lines
ensures that if the comment string ends with a "$" it is not treated
as an anchor.
I am not sure what this means. Wouldn't these three
sed -e '/^#/d'
sed -e '/^#.*/d'
sed -e '/^#.*$/d'
work exactly the same way?
They do, but if the comment string is '$' then these two
sed -e '/^$/d'
sed -e '/^$.*/d'
have different meanings
Ahh, that is what you meant.
Having to write "/^\$/" is inconvenient, because others characters
do not generally need the backslash (e.g., "/^\#/" and "/^#/" are
the same) and some characters even may become nonsensical if we
blindly add backslash to everybody (e.g., "/^\1/").
Nobody would use "[" as a commentchar, I hope, as "/^[/d" would not
work, and neither "/^[.*/d" does.
Thanks.