Reputation: 65
I am trying to find a particular string in files on my server. I have done the following which gives me a list of files, but how do I now delete them?
grep -H -r "example" /home/72754/domains | cut -d: -f1
Upvotes: 0
Views: 437
Reputation: 1631
Try this if you want to delete files:
grep -l -r "example" /home/72754/domains | xargs rm
Upvotes: 1
Reputation: 42799
You can use sed
with the same pattern and change what you want
If you want to delete the whole line then something like this
sed '/example/d' /home/72754/domains
And to update the same file, use the -i
flag
If you want to update a certain pattern, you can use something like this
sed 's/password/****/' /file
And again you can use the -i
flag to update and overwrite the file
Upvotes: 0