Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question
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 9:09

1 Answer 1

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: serverfault.com/questions/500122/… –  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

 
discard

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.