Is there some way to implement all files with no extension using asterisk? I want to use it in Makefile or .gitignore implementation to remove or ignore all non-extension files such as README, Makefile and complied C file. When I use just rm *
format, it delete ALL files regardless of extension, while I want to control ONLY non-extension files.
I will assume that a file name with no extension means without a dot.
In a .gitignore
file you can include again (with !pattern
) files that have been excluded by a previous pattern. So:
*
!*.*
should ignore all files (or directories) without extension.
In a Makefile
you can use functions or macros provided by your version of make (which you forgot to indicate). Example if you use GNU make with wildcard
and filter-out
:
ALL := $(wildcard *)
WITH_EXTENSION := $(wildcard *.*)
WITHOUT_EXTENSION := $(filter-out $(WITH_EXTENSION),$(ALL))
.PHONY: test
test:
@echo $(WITHOUT_EXTENSION)
Note: it would have been be better to ask two different questions.