Sample Header Ad - 728x90

String replace in wildcard using find command

0 votes
1 answer
67 views
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.
Asked by Ryan Maguire (3 rep)
Nov 6, 2024, 07:38 PM
Last activity: Nov 6, 2024, 09:25 PM