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

1
  • 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"? Apr 17, 2013 at 9:09

1 Answer 1

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.

5
  • 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, 2013 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. Apr 17, 2013 at 9:25
  • you forgot the -path argument? Apr 17, 2013 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: serverfault.com/questions/500122/…
    – rubo77
    Apr 17, 2013 at 9:40
  • I have it!!! find /var/www/ -path '*wp-admin/index.php' -exec mv {} {}_disabled \; thanks!!! ;)
    – rubo77
    Apr 17, 2013 at 9:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .