Published on

Editing a File with Cat


In one of my previous posts I recounted how I ran into a docker container where there was no editor anywhere in the container's shell. This happened again today. A colleague who was working through the issue with me pointed out a more elegant solution:

  • Edit the file on your local machine however you normally would
  • Exec into the container in interactive mode kubectl exec -it podName -- /bin/sh
  • Copy all the contents of the file into your local machine's clipboard
  • In your pod's shell type: cat <<'EOF' >>
    • Where is a file that exists on the pod where you want to paste the changes to
  • Paste the contents from your local clipboard into the shell
  • Push enter then type EOF
  • Finally push enter once more and the file on your pod will have the contents you want