Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove an entire line which matches a pattern

The following pattern matches an entire line, how do I search and remove these lines. If I leave a space in the replace string, it leaves a blank in that particular line, when I do via eclipse.

^[\t ]*<param name="logic" .*$
like image 783
Joe Avatar asked Sep 16 '10 09:09

Joe


People also ask

How do you delete a line with a pattern in Linux?

To begin with, if you want to delete a line containing the keyword, you would run sed as shown below. Similarly, you could run the sed command with option -n and negated p , (! p) command. To delete lines containing multiple keywords, for example to delete lines with the keyword green or lines with keyword violet.

How do you erase a line?

Place the text cursor at the beginning of the line of text. On your keyboard, press and hold the left or right Shift key and then press the End key to highlight the entire line. Press the Delete key to delete the line of text.


1 Answers

I don't know anything about eclipse but you may need to include the \n newline match in order to remove the line completely. Also - is it possible to replace with an empty string as opposed to a space?

^[\t ]*<param name="logic" .*\n$
like image 172
El Ronnoco Avatar answered Oct 03 '22 01:10

El Ronnoco