How to write loop in a Makefile?

后端 未结 12 2275
天命终不由人
天命终不由人 2020-11-27 09:38

I want to execute the following commands:

./a.out 1
./a.out 2
./a.out 3
./a.out 4
.
.
. and so on

How to write this thing as a loop in a

12条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 10:16

    #I have a bunch of files that follow the naming convention
    #soxfile1  soxfile1.o  soxfile1.sh   soxfile1.ini soxfile1.txt soxfile1.err
    #soxfile2  soxfile2.o   soxfile2.sh  soxfile2.ini soxfile2.txt soxfile2.err
    #sox...        ....        .....         ....         ....        ....
    #in the makefile, only select the soxfile1.. soxfile2... to install dir
    #My GNU makefile solution follows:
    tgt=/usr/local/bin/          #need to use sudo
    tgt2=/backup/myapplication/  #regular backup 
    
    install:
            for var in $$(ls -f sox* | grep -v '\.' ) ; \
            do \
                    sudo  cp -f $$var ${TGT} ;     \
                          cp -f  $$var ${TGT2} ;  \
            done
    
    
    #The ls command selects all the soxfile* including the *.something
    #The grep command rejects names with a dot in it, leaving  
    #My desired executable files in a list. 
    

提交回复
热议问题