Artificial intelligent assistant

Select and remove lines matching a pattern from a file grep -Eri "drucken" app/views app/views/meths/_form.html.erb: <li class="hidden-phone"><a onclick="javascript: print();" class="">Methode drucken</a></li> app/views/clients/show.html.erb: <li><a onclick="javascript: print();" class="" value="drucken">drucken</a></li> app/views/clients/index.mobile.html.erb: <li class="hidden-xs"><a onclick="javascript: print();" class="">KlientInnen drucken</a></li> app/views/treatments/index.html.erb: <li><a onclick="javascript: print();" class="" value="drucken">drucken</a></li> I'm looking for a solution where I could do something like: grep -Eri "drucken" app/views | xargs INTO_A_FANCY_TOOL_WHICH_REMOVES_THOSES LINES **update:** I want to remove those lines from the file.

Did you try something like:


grep -Eri -l "drucken" app/views | xargs sed -e '/drucken/d' -i


where '-l' tells grep to only print the file name, '-i' tells sed to modify that file on the fly.

Alternatively you could loop with sed over all files, but it will "touch" all of them even if the file doesn't contain the requested word:


find app/views -type f -exec sed -e '/drucken/d' -i {} \;

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 692006b387f5257c4e7e1e30df3a7be7