Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 删除命令行返回的第一条白线_Bash_Kubernetes_Kubectl - Fatal编程技术网

Bash 删除命令行返回的第一条白线

Bash 删除命令行返回的第一条白线,bash,kubernetes,kubectl,Bash,Kubernetes,Kubectl,我正在使用kubernetes,我想从应用程序名中获取podname。这是我使用的命令 POD=$(kubectl get pods -l app=influxdb-local -o custom-columns=:metadata.name -n influx) 然后,我想将结果用于: kubectl exec -it -n influx $POD -- influx -username user -password "user" -execute "CREATE DATABASE db"

我正在使用kubernetes,我想从应用程序名中获取podname。这是我使用的命令

POD=$(kubectl get pods -l app=influxdb-local -o custom-columns=:metadata.name -n influx)
然后,我想将结果用于:

kubectl exec -it -n influx $POD -- influx -username user -password "user" -execute "CREATE DATABASE db"
但是第一行是空的,第二行包含pod名称,所以第二个命令不起作用

如何删除第一条白线?

添加
--no headers
跳过标题行

kubectl get pods -l app=influxdb-local -o custom-columns=:metadata.name -n influx --no-headers
自定义列 使用标志
-o custom columns=:
可以自定义输出

标题
name

kubectl get pods -o custom-columns=NAME:metadata.name
输出

NAME
myapp-5b77df6c48-dbvnh
myapp-64d5985fdb-mcgcn
httpd-9497b648f-9vtbl
空标题名称:您将标志用作
-o自定义列=:metadata.name
-第一行是标题行,但标题为空

省略标题 省略标题行的正确解决方案是使用标志
--no headers

kubectl get pods -o custom-columns=NAME:metadata.name --no-headers
示例输出

myapp-5b77df6c48-dbvnh
myapp-64d5985fdb-mcgcn
httpd-9497b648f-9vtbl