Home > Back-end >  How to copy every line in text file containing substring
How to copy every line in text file containing substring

Time:09-27

I have a text file I've been viewing in visual studio code:

here is one line
problem path: path1
another line
value line more info
value
problem path: path2
incredible data line
problem path: path3

And I want to copy every line which includes with the text problem path: so my output result will look like

problem path: path1
problem path: path2
problem path: path3

Can i ctrl f search for 'problem path' in my text file, select every line where it occurs, and copy/paste those lines into a new file?

CodePudding user response:

  • open find box Ctrl F
  • type problem path: or some regex
  • press Alt Enter
  • press Home incase a line contains multiple finds and to get only a cursor and not a selection on the line
  • press Ctrl C
  • in the other file: Ctrl V

CodePudding user response:

This is the expression you can use https://regex101.com/r/wJVNJR/1

Find: problem path:.

You have to use a programming language to write the content to a separate file.

  • Related