Apply find command and exec on "Find results"

Hi everyone, is it possible to apply “find” on “found” results, how many times this is possible?

First i would like to find Folders with a “common_name” that are located in many Project_folders under different names. When I find this folders i would like to find all excel files into them and erase them so first i thought:

find . -type d -name \Folder_keeping_excel_files -exec find {} -type f -name “*.xlsx” [and here should come another command to delete de found excel files]

My question, is it possible to concatenate many finds and many “-exec” ? until now I got errors or the exec that should be executed on the found excel files it’s been executed on other excel files…

I’ll appreciate any help and examples!!

Cheers from Hamburg!!

Never tried it like that. So no idea. However, this seems like a bad idea. What are you trying to solve? Do you just want to find out all *.xlsx files in a given folder?

Hi, and thanks for answer.

I would like to find them and delete (or better “shred” ) them.

Hi!

This helped me:

find test_folder/ -type d -name “excel_folder” -exec sh -c ‘find “$0” -type f -name “*.xls” -exec shred \ { \ } -n 7 -vuz \ ;’ \ { \ } ;

it worked like a charm!!

Here is the command you should try next time

find path/to/folder -type f -name "*.xls" -delete

OR

find path/to/folder -type f -name "*.xls" -exec shred -n 7 -vuz {} \;

See
https://www.cyberciti.biz/faq/linux-unix-how-to-find-and-remove-files/

1 Like

Totally agree if you know where the right folder is, if you don’t you should first find the right folder and then look after the *.xls files