I want to exclude all C
files that have a matching asm
file. The assembly files all have _x86_64.S
at the end. The C
files have identical names, but with .c
instead of _x86_64.S
at the end. How would I do something like:
find . -not -name *{_x86_64.S but replace with .c}
So, for example, if my_func.c
and my_func_x86_64.S
exist, then
the file my_func.c
will be excluded by the above command.
Edit: The answer provided below works. I forgot to mention I was using this in a Makefile. What I had been doing was the following:
ASM_FILES = $(shell find ./src/assembly/x86_64/ -name "*.S" -printf "-not -name \"*%f*\" -and ")
ASM_INCLUDE += -wholename "./src/assembly/x86_64/*.S" -or
EXCLUDE += $(subst _x86_64.S,.c,$(ASM_FILES))
This works, but I was hoping for something a little cleaner.
-wholename
,-printf
,-or
,-not
,-and
are all non-standard GNUisms (well, the last 3 actually from BSDs I believe), so shouldn't be used in a Makefile unless that's to build software intended for GNU systems only.pkg install gmake
so I abandoned aiming at POSIX compliance after much effort. If I am mistaken, and conditionals are possible (i.e.ifeq
), please let me know!