The current find command is utilized to find and delete outdated files and directories. The expired data is based on a given properties file and the destination. If the properties file says…
"/home/some/working/directory;.;180"
…then we want files and empty subdirectories deleted after 180 days. The original command is…
"find ${var[0]} -mtime ${var[2]} -delete &"
…but I now need to modify now that we've discovered is has deleted symbolic links that existed in specified sub-directories after the given expiration date in the properties file. The variable path and variable expiration time are designated in the properties file (as previously demonstrated).
I have been testing using…
"find -L"
…to follow the symbolic links to make sure this clean up command reaches the destinations, as desired. I have also been testing using…
"\! -type l"
…to ignore deleting symbolic links, so the command I've been trying is…
"find -L ${var[0]} ! -type l -mtime ${var[2]} -delete &" …but I haven't achieved the desired results. Help please, I am still fresh into Linux and my research hasn't lead me to a desired answer. Thank you for your time.
CodePudding user response:
Change \! -type l to \! -xtype l
find -L ${var[0]} \! -xtype l -mtime ${var[2]} -delete &