0

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

/var/www/

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 ;)

rubo77
  • 2,282
  • 3
  • 32
  • 63
  • 2
    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 09:09

1 Answers1

1

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.

rubo77
  • 2,282
  • 3
  • 32
  • 63
  • 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 09: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 09:25
  • you forgot the -path argument? – Mauritz Hansen Apr 17 '13 at 09: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: http://serverfault.com/questions/500122/how-do-i-use-the-operator-twice-in-find-exec – rubo77 Apr 17 '13 at 09:40
  • I have it!!! `find /var/www/ -path '*wp-admin/index.php' -exec mv {} {}_disabled \;` thanks!!! ;) – rubo77 Apr 17 '13 at 09:57