Evolution48
Evolution48

Reputation: 169

I set this server commando in php?

I need to get this command:

awk '{w=NF?$NF:w} END{print w}' file.log

in PHP

$land = system(" awk '{w=NF $NF:w} END{print w}' file.log");

I tried like this but PHP thinks that $NF is a variable...
so I need the last field of a log file!

Upvotes: 0

Views: 44

Answers (1)

tino.codes
tino.codes

Reputation: 1507

Escape the $NF "variable" like this

$land = system(" awk '{w=NF \$NF:w} END{print w}' file.log");

Upvotes: 1

Related Questions