-1

I am trying to delete some line in PHP files. I tried to use an find, exec combination:

find . -name '*.php' -exec sed '/@category/d' {} \;

but it only prints out the files contents. Is there anythin wrong in the syntax? Or what is the problem?

Jens Peters
  • 1,975
  • 1
  • 21
  • 30

3 Answers3

3

Could you try this command:

find . -name '*.php' -exec sed -i '/@category/d' {} \;

I think you've missed -i option

Vahid Farahmand
  • 2,488
  • 2
  • 13
  • 20
1

It works, but probably not how you expect.

find . -name '*.php' -exec sed -i '/@category/d' {} \;

Will kill the lines in question.

ldav1s
  • 15,327
  • 2
  • 51
  • 55
1

This should be the command for sed so try to add -i :

sed -i ".bak" '/culpa/d' test.txt

find . -name '*.php' -exec sed -i '/@category/d' {} \;

Source of the answer: Bash - find a keyword in a file and delete its line

Community
  • 1
  • 1
Mehdi Karamosly
  • 5,162
  • 2
  • 27
  • 48