0

I have the directory structure like

/Folder1/Folder1a/Folder1b
/Folder1/Folder2a/Folder2b
/Folder1/Folder2a/Folder2c
/Folder1/Folder3a
/Folder1/Folder4a

I want to recursively delete the files from /Folder1/ but want to exclude the location /Folder1/Folder2a/Folder2c.

  • See http://stackoverflow.com/questions/17184956/how-exclude-files-folders-for-remove – Alexander Kohler Apr 03 '17 at 16:23
  • It gives a basic idea but i want to delete the files and exclude the directory completely I had tested this find /Folder1/ -type 'd' | grep -v "/Folder1/Folder2a/Folder2c" | xargs ls -l {} \; & – JhawarMayank Apr 03 '17 at 16:29
  • `find . -type 'f' | grep -v "Folder1/Folder2a/Folder2b" | xargs rm` doesn't do what you're looking for? – Alexander Kohler Apr 03 '17 at 16:39
  • I think i wrote the question wrong i need to exclude a couple of folders from the deletions and i need to keep the data in all directories for 45 days, i modified it a little and came up with this nohup find /Folder1/ -type 'd' -mtime +45 | grep -v "NameToExclude" | xargs ls -l {} \; & – JhawarMayank Apr 03 '17 at 17:17

0 Answers0