Team, I read many posts but its unclear to me..
I need to understand how to deal with this.. I have xargs doing some evaluation and then am piping to awk but get syntax error
file.log
node1,
node2,
node3,
failing expression with xargs and awk
cat file.log | awk -F ',' '{print $1}' | xargs -l1 -- sh -c 'kubectl get pods --all-namespaces --no-headers --field-selector spec.nodeName=$1 | awk "{if ($1 ~ "team-") print $1,$2}"' --
passing till here
cat file.log | awk -F ',' '{print $1}' | xargs -l1 -- sh -c 'kubectl get pods --all-namespaces --no-headers --field-selector spec.nodeName=$1
as soon as i add awk part..am not getting it.
output:
awk: line 1: syntax error at or near )
Alternate solution I found is move the awk out of xargs --. so below works. but how can i get the awk inside because I would like to print the $1 that am using in xargs to see correlation with what awk is printing.
WORKS
--field-selector spec.nodeName=$1' -- | awk '{if ($1 ~ "team-") print $1,$2}'
FAILS
--field-selector spec.nodeName=$1 | awk '{if ($1 ~ "team-") print $1,$2}' --