find directories and change ownership using bash

123 Views Asked by At

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'

1

There are 1 best solutions below

2
rumon On

Try using

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