About using find with prune option

Unix & Linux Asked by Dominique Crétel on January 2, 2022

I have a source folder where you can find files with extensions .c, .pc, .pro.c.

I want to find all files with .c and .pc only, since .pro.c is a generated file from .pc after preprocessing.

Here is my find expression which is not yet correct:

find source ( ( -name '*.pro.c' ) -a -prune ) -o ( -name '*.c' -a -print )

What is my mistake ?

Can someone help me and explain why I do not get the correct result ?

Thank you.

One Answer

-prune applies to directories, not files, and instructs find not to descend into the directory it’s looking at.

You only need to negate a name test:

find source -name '*.c' ! -name '*.pro.c' -o -name '*.pc'

Answered by Stephen Kitt on January 2, 2022

Add your own answers!

Related Questions

Sed command writes the expression in outer ifmodule

1  Asked on January 9, 2021 by ariana-williams


Netctl is slow in arch linux

1  Asked on January 9, 2021 by fenil-shah


How to default `ps aux` to `ww`?

0  Asked on January 7, 2021 by nicholas-dipiazza


Earphone’s mic does’t work on fedora linux

0  Asked on January 6, 2021 by vedant-nandwana


Parallelize a Bash FOR Loop

10  Asked on January 6, 2021 by ravnoor-s-gill


List only bind mounts

5  Asked on January 6, 2021 by l0b0


Addition with ‘sed’

12  Asked on January 5, 2021 by luigi-tiburzi


Muon is stuck on lubuntu cosmic. How do I get off this dead end?

1  Asked on January 5, 2021 by cw-holeman-ii


Where are defined the man pages grouping descriptions?

1  Asked on January 5, 2021 by lus-gustavo-monezi


xrandr three monitors

2  Asked on January 5, 2021 by ben-flowers


Adding iptables rules after implementing fail2ban

1  Asked on January 5, 2021 by mike-dank


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP