1

I want to exclude some large content directory

I'm Using it to chown Directory

chown -R admin /home/admin/web/public_html

is there anyway to exclude a subdirectory under html

Like:

chown -R admin exclude=/home/admin/web/public_html/content /home/admin/web/public_html

Something like that

Thanks

Mitra
  • 362
  • 1
  • 2
  • 11
  • chown does not do that. Only solution I see if to use the find command to get a list, `grep -v` what you want to exclude, then run the chown in a loop on the list of files. – Nic3500 Mar 19 '18 at 19:17
  • Thanks @Nic3500 Please show me the command code. because I had try a find – Mitra Mar 19 '18 at 19:26
  • Look up `find -type f` options, `while`, `grep -v` – Nic3500 Mar 19 '18 at 19:29
  • I try that: `find . -type d \( -path contents -o -path admin/logs -o -path admin/data/backup -o -path admin/data/conversion -o -path admin/smarty/cache -o -path admin/data/engine/storage -o -path 78 -o -path 976 -o -path tmp \) -prune -o -print | xargs chown -R admin` – Mitra Mar 19 '18 at 19:38
  • Can you please give me an example command – Mitra Mar 19 '18 at 19:39
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Mar 19 '18 at 23:25
  • I hope this can help https://stackoverflow.com/questions/3740152/how-do-i-set-chmod-for-a-folder-and-all-of-its-subfolders-and-files-in-linux-ubu – jarry jafery Apr 02 '18 at 11:19

1 Answers1

1

You can to use a script with a loop, similar to this:

path_list=$(find /home/admin/web/public_html)

for path in $path_list
do
   if test $path != "/home/admin/web/public_html/content"
   then
       chown -R admin $path
   fi
done
AlmuHS
  • 387
  • 6
  • 13