Как я могу изменить этот скрипт, чтобы удалить также и каталоги?

find /folder/*.* -mtime +14 -exec rm {} \;

Я пытался rm -r и с -R аргументом, но безрезультатно.

0
задан 4 March 2014 в 12:20

2 ответа

find /path/to/directory -type d -ctime +14 -exec rm -rf {} \;

find: unix command for finding file and directories .
/path : state directory path
-type d : only find directories 
-ctime +14 : only consider ones with modification older than 14 days
-exec for such result do the following
rm -rf {} recursively force remove the directory 
0
ответ дан 4 March 2014 в 12:20

Попробуйте это:

find /folder/*.* -mtime +14 -exec rm -Rf {} \;
  
find:  
       search for files in a directory hierarchy
-mtime n: File's data was last modified n*24 hours ago.
-exec command ; Execute command;
-exec command {} + This variant of the -exec action runs the specified command on the selected files rm: remove files or directories
-r, -R, --recursive remove directories and their contents recursively -f, --force ignore nonexistent files, never prompt {} Remove (unlink) the FILE(s).

Этот поиск сценария файлов и удаляет рекурсивно файлы/папки, которые составляют 14 дней вдоль измененного

0
ответ дан 4 March 2014 в 12:20

Другие вопросы по тегам:

Похожие вопросы: