Saturday, February 24, 2024
rated 0 times [  15] [ 0]  / answers: 1 / hits: 23751  / 2 Years ago, sun, october 3, 2021, 7:23:21

I have a folder /home/userA/folderA this folder contains many files and folders and subfolders. What I want to do is to delete all files that have certain names data.txt and glass.txt. I also want to delete any folder named match with all its contents. I'd be thankful for any advice in how to do this.

More From » command-line


You can delete the files and folders in the subdirectories of folderA.

To remove the files, run:

find /home/userA/folderA/* -type f ( -name "data.txt" -or -name "glass.txt" ) -delete 

and to remove the folders match:

find /home/userA/folderA/* -depth -name "match" -type d -exec rm -rf "{}" ; 

[#23036] Tuesday, October 5, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 454
Total Questions: 98
Total Answers: 122

Location: Philippines
Member since Sat, Jul 11, 2020
4 Years ago