kubectl exec 命令将内容写入 pod 中的文件

Kubectl exec command to write contents to a file in the pod

我正在尝试以下命令

kubectl exec -it sss-pod-four  echo "hi" >> /mnt/sss/testnew.txt

但是它抛出错误

-bash: /mnt/sss/testnew.txt: No such file or directory

实现此目标的最佳方法是什么

发现了一个类似的问题并且下面的命令现在有效

 kubectl exec -it sss-pod-four  -- bash -c "echo hi > /mnt/sss/testnew.txt"