Chris
Chris

Reputation: 31256

Awk field values inside make file

I have a makefile, and I am trying to use awk in a one liner inside of it:

# makefile
...
SHELL := /bin/bash

my_rule:
    ls dir | awk -v path=$(current_dir) '{print path"/"$1}' > some_file

however, I can't seem to get make to drop the $1 into awk. How do I escape/access the field variables in awk, within the makefile?

Upvotes: 1

Views: 146

Answers (2)

runwuf
runwuf

Reputation: 1717

This should do it:

# makefile

SHELL := /bin/bash

my_rule:
    ls dir | awk -v path=$(current_dir) '{print $$path"/"$$1}' > some_file 

Upvotes: 2

RavinderSingh13
RavinderSingh13

Reputation: 133650

Try changing $ to $$ in makefile to make awk read it as correct field.

Upvotes: 2

Related Questions