I have a file like below. It has around 300 lines like below. All the lines starting with # are comments.
For readability, I removed all lines starting with # from vi (vim editor) using the command :g/^#/d . It seemed to have worked.
But, which is more accurate/safe :g/^#/d or :g/^ *#/d and why ? This is super-important configuration file. Hence I want to use the most accurate command.
$ cat config.properties
#some comment1
parameter1=blablah
#some more comment2
another parameter=blablah
#another comment3
parameter3=xyz
The second is the more reliable. If there is space before the # comment characters, it is still a comment. Even more reliable would be to remove possible TAB characters as well
Thank You scrutinizer. :g/^ *#/d cannot take care of TABs.
ie. It cannot remove the line with #some comment1 shown below which has a TAB at the beginning. Any idea , how lines with TABs can also be dealt with ? Using vi or some other utility ?
$ cat config.properties2
#some comment1
parameter1=blablah
#some more comment2
another parameter=blablah
#another comment3
parameter3=xyz
I like this URL
The \s is in chapter "Perl Extensions".
In Linux the perl extensions sneak into the BRE and ERE, but they are not standard.
I would use them only in perl.
The books mentioned at the bottom of the above page are good too.
Jeffrey Friedl's book on regular expressions is the most advanced and a gold mine of information.