Vinay Vishwkarma
Vinay Vishwkarma

Reputation: 27

How to delete common files under subfolders in mac using terminal

i have directory like

dir A

--B file a

--c file a

--D file a

A is parent dir and B, C and D are child of A and all child folder contain a file a which i want to delete in one go using terminal. I tried below cmd but did not work

find. -regex '\b[FreeCoursesOnline.Me].url\b' -print0 | xargs -0 rm

Upvotes: 0

Views: 92

Answers (2)

Vinay Vishwkarma
Vinay Vishwkarma

Reputation: 27

Not exactly but below cmd can work

find . -name '*.txt' -delete

we can find out all the all the file with specific extension and can delete in one go

Upvotes: 0

erik258
erik258

Reputation: 16285

It's not your method that's wrong - it's just your regex.

How to use regex with find command? talks about using the regex with the find command, and what regex flavor it might support. In any case, [ and ] have special meaning. Outside of [], . also has special meaning. As far as I could determine with a quick glance, none of the find implementations I saw provided a regex engine that supported the \b word boundary.

Upvotes: 1

Related Questions