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

I want to rename all wordpress admin index files into index_disabled in the folder


I need a script like

find /var/www/ -path '*wp-admin/index.php' -exec mv {} $(dirname {})/index_disabled

but this doesen't work like this

the problem is this: How do i use the {} operator in find execution inside exec

my bash skills are not good enough to complete this ;)

share|improve this question
The bash code will be nearly trivial but you have to explain what exactly you want. What do "all files like" and "$(locate wp-admin/index.php)" stand for? "All files in a known directory"? "All *.php files"? "A directory that needs to be found"? – Hauke Laging Apr 17 '13 at 9:09
up vote 1 down vote accepted

You can use the find command for this:

find /var/www/ -path '*wp-admin/index.php' -exec mv -v {} {}_disabled \;

This will rename all files to {old_name}_disabled.

share|improve this answer
this doesent work: Warnung: Unix Dateinamen enthalten gewöhnlich keine Schrägstriche (anders als Pfadbezeichnungen). in english something with slash in filenames – rubo77 Apr 17 '13 at 9:15
for finding a path and file combination you will indeed need to use the -path argument to find instead of the -name argument. I have updated my answer accordingly. – Mauritz Hansen Apr 17 '13 at 9:25
you forgot the -path argument? – Mauritz Hansen Apr 17 '13 at 9:38
ok, so i need something like this: find /var/www/ -path '*wp-admin/index.php' -exec mv {} $(dirname {})/index_disabled but that doesent work ;) the problem is this:… – rubo77 Apr 17 '13 at 9:40
I have it!!! find /var/www/ -path '*wp-admin/index.php' -exec mv {} {}_disabled \; thanks!!! ;) – rubo77 Apr 17 '13 at 9:57

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.