Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
find . -name '.htaccess' -print | xargs grep -il 'sound' | xargs -p sh -c ">{}"

Trying to find some .htaccess files on a host that've been compromised, grep them to make sure they are bad .htaccess (not all on server have been ruined) and blank them out.

All is working, except the last part. Tried many variations of echo > etc.

I'm missing a fundamental here and can't seem to grok it out of all the man pages.


share|improve this question
up vote 1 down vote accepted
find . -name '.htaccess' -print | xargs grep -il 'sound' | xargs -I {} sh -c ">{}"

Per usual, I get it minutes after posting a question.

Think it helps sometimes to just spell it out (literally)...

share|improve this answer

Try it with the : > filename noop.

But would it not make more sense to remove the bad .htaccess files rather than zero them?

share|improve this answer
Maybe... they're there as a result of other apps (joomla, etc; hence the hacked htaccess). Interestingly, the original htaccess files seem to be intact in the directory in other forms (e.g. htaccess.txt). Right now, just want them 0'd. Also, I took out the php exec($_GET) backdoor that they were using, so for now... – stormdrain Aug 23 '12 at 19:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.