experchange > shell

bubunia2000ster (01-10-19, 05:13 AM)
Hi all,

I am writing a small bash script as below.

[root]# kubectl get pods --all-namespaces |grep -i Terminating |awk '{print("kubectl delete pod -n", $1, $2 --grace-period=0 --force);}' | sh
awk: cmd. line:1: {print("kubectl delete pod -n", $1, $2 --grace-period=0 --force);}
awk: cmd. line:1: ^ syntax error
[root]#

When I want to pass the --grace-period= and --force option the script fails with the error.

Can anyone help me in this regard?

Regards
Pradeep
Lew Pitcher (01-10-19, 05:23 AM)
bubunia2000ster wrote:

[..]
> When I want to pass the --grace-period= and --force option the script
> fails with the error.
> Can anyone help me in this regard?


Just as you did for the first part of the output ("kubectl delete pod -n"),
put quotes around the other parts of the output that you dont want awk to
interpret.

{print("kubectl delete pod -n", $1, $2, "--grace-period=0 --force");}