Re: Text file editing - remove trailing comments?



Mike Jones wrote:

I have a long file with more lines than I fancy manually editing, and need to cut all the added comments from any lines that have them.

ie:

line1
line2 # comments
line3
line4 # with notes
line5 # more stuff

...becomes

line1
line2
line3
line4
line5

Anybody got quick'n'simple technique for this kind of thing?


Load the file into vi and do command

:%s/#.*\n/^M/g

and all those comments disappear.

I get that ^M by doing Ctrl+v Ctrl+m

Stuart
.



Relevant Pages