Score:0

script on changing directory ownership via bash

cn flag

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:oinstall {}"

Alex avatar
us flag
What exactly is now working? Do you get any error, or any undesired behaviour?
nick avatar
cn flag
find: missing argument to `-exec
Score:1
bd flag

The syntax of find is a bit tricky, especially with -exec. Try:

 find /mnt/mailfolder/ -maxdepth 1 -type d -mtime +150 -printf "%P\n" -exec chown -R oracle:oinstall "{}" \;
nick avatar
cn flag
many many thanks. ive understood what needs doing. much appreciated
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.