0

The following command attempts to copy /.htaccess to all folders permission 0777

find /home/*/www/ -type d -perm 0777 \
| xargs -r -d '\n'  cp -rf /.htaccess

am looking to run it with terminal ssh command

i search for all folders have 0777 and copy htaccess to all at once

Mikel Tawfik
  • 658
  • 3
  • 9
  • 23

3 Answers3

0

find /home/*/www -type d -perm /0777 -print0 | xargs -0 -I{} -r -P4 -n1 cp /.htaccess '{}'

You want to use print0 combined with xargs -0 so that it can handle IFS characters.

Use xargs -n1 so that it only tries to copy to one directory at a time.

I use xargs -I{} to be more explicit in what I'm doing.

xargs -P4 will parallelize it 4 times to increased speed.

Oliver I
  • 436
  • 1
  • 3
  • 12
0

Rather than bothering with xargs, you can just use the -exec option to find:

$ find . -type d -perm \0777 -exec cp /.htaccess {} \;
Jack
  • 5,801
  • 1
  • 15
  • 20
  • looking for help here https://stackoverflow.com/questions/44978623/how-to-export-ssl-key-crt-and-ca-from-httpd-conf-apache-to-use-it-into-nginx-f – Mikel Tawfik Jul 07 '17 at 21:39
0
find /home/*/www/ -type d -perm 0777 \
| xargs -I '{}' cp -rf  /.htaccess  '{}'
Mikel Tawfik
  • 658
  • 3
  • 9
  • 23