Kimvais
Kimvais

Reputation: 39548

How to access a file created by a recipe in the next step when the file name is arbitrary

I have a Makefile that is something like this:

target:
         command_that_creates_a_file_with_arbitrary_filename
         i_want_to_something_with_the_newest_file_in_directory_x

doing FILENAME=$(shell ls -1t directory_x |head -n 1) will give me the filename of the previous round, as would inlined $(shell ...)

Upvotes: 0

Views: 34

Answers (1)

MadScientist
MadScientist

Reputation: 100856

You cannot use make functions to find the file. But why do you want to? You're already IN a shell, to execute the recipe. Using the make shell function is just redundant.

target:
         command_that_creates_a_file_with_arbitrary_filename
         newfile=`ls -1t directory_x |head -n 1`; i_want_to_something_with $$newfile

Upvotes: 2

Related Questions