Deleting a line in a file with Thor
1 answer
Doesn't this work for deleting comments?
gsub_file(filename, /#.*$/, '')
Edit:
If you want to remove comments and remove lines with only comments, you can try:
gsub_file(filename, /\S*#.*$/, '') # removes partial comments
gsub_file(filename, /^\s*#.*\n/, '') # removes full line comments
+5
source to share