-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
  • 2,075
  • 1
  • 22
  • 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,528
  • 2
  • 14
  • 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,885
  • 2
  • 53
  • 56
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,388
  • 2
  • 32
  • 50