1

I am trying to find directories older than 150 days and change their ownership as root. Please can you advice on how do i fix the below pls?

find /mnt/mailfolder/ -maxdepth 1 -type d -mtime +150 -printf "%P\n" -exec "chown -R oracle:oinst

find: missing argument to `-exec'

Cyrus
  • 84,225
  • 14
  • 89
  • 153
nick
  • 99
  • 7
  • You need to add `{} \;` to the exec where `{}` refers to the found file (which is the missing arg) `-exec chown -R oracle:oinst {} \;` – Michael Berkowski Oct 29 '21 at 12:06
  • thanks. It finds the folder but fails on the chown "N01 find: ‘chown -R oracle:oinstall’: No such file or directory " – nick Oct 29 '21 at 12:12

1 Answers1

-1

Try using

find /home/$USER -mtime +150 -print && chown -R root:root /home/$USER

rumon
  • 17
  • 9
  • It messed up every folder with "oracle:oinstall" I ran what u advised ```find /mnt/mailfolder/$folder -maxdepth 1 -type d -mtime +150 -printf "%P\n" && chown -R oracle:oinstall /mnt/mailfolder/$folder ``` – nick Oct 29 '21 at 12:18
  • && does not look at the first half of the script and changes directory to every folder – nick Oct 29 '21 at 12:21