I have a shell script use awk from https://devconnected.com/monitoring-linux-processes-using-prometheus-and-grafana/.
#!/bin/bash
z=$(ps aux)
while read -r z
do
var=$var$(awk '{print "cpu_usage{process=\""$11"\", pid=\""$2"\"}", $3z}');
done <<< "$z"
echo $var
I know the $3 means the third matched string split by space. What is the $3z
mean? Is z
the param of read -r z
? when I substitute $3z
to $3
, it changed nothing, why?