0

I'm trying to extract the 6 from a file called ~/Downloads/GGG/some_file.6.txt in makefile. I got pretty close, and managed to get .6, but I can't seem to get rid of the dot . and get just the 6. Here is my makefile:

FILE = ~/Downloads/GGG/some_file.6.txt

another_file.txt: ${FILE}
    @echo $<
    @echo $(suffix $(basename $<))
    @cp $< $@

Here is the result:

$ make
/home/oren/Downloads/GGG/some_file.6.txt
.6

How can I get rid of the dot?

OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
  • If you have more and more complex string manipulations to complete, you may take a look at [the GNUmake table toolkit](https://github.com/markpiffer/gmtt). See e.g. an answer here: https://stackoverflow.com/questions/58087491/make-detect-platform-with-regex/58092842#58092842 – Vroomfondel Sep 26 '19 at 11:16

1 Answers1

1

You can try:

@echo $(patsubst .%,%,$(suffix $(basename $<)))
MadScientist
  • 92,819
  • 9
  • 109
  • 136