Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want the results from an ls to be saved in a var inside a makefile the command is simply the following:

ls text* 

and the result suppose to be something like : text1.txt What i put in my script is:

text = some commands to fetch the "text" .
com = `ls $(text)*`

What is actually saved at $com is the results of the entire ls without the $(text)* parameter.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

IIRC, Pure posix make doesn't allow that. You'll need to resort to some kind of extension provided by the precise version of make you are using. For example with GNU make

com=$(wildcard $(text)*)

or nearer to what you are asking, but launch an additional shell

com=$(shell ls $(text)*)

share|improve this answer
1  
@Iraklis Use com=$(wildcard $(text)*). Calling ls here has no benefit and might occasionally cause trouble. Also, note that a variable is expanded each time it is used; this might make a difference if you use $(com) inside a command that creates some files that would match. If you want the value to be computed when the variable is defined, use com := $(wildcard $(text)*). –  Gilles Nov 28 '11 at 17:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.