0

I am executing the following commands over ssh and then past it to kubectl exec.

ssh -i 'path\to\file' user@host 'kubectl exec -i pod-name -- bash -c "du --max-depth=1 /home -h -t 10M | sort -hr > users.txt ; for i in `cat users.txt` ; do echo $i ; ls -lrtah $i ; done"' 

I am trying to display all user directories under /home with more than 10M in size and then redirect the output to users.txt then pass it to a for loop to display all the files inside each directory but Instead, I get an error:

cat: users.txt: No such file or directory

But when I ran the command without the for loop, it displayed the directories.

ssh -i 'path\to\file' user@host 'kubectl exec -i pod-name -- bash -c "du --max-depth=1 /home -h -t 10M | sort -hr 
4
  • Hint: the command substitution is performed before kubectl runs. Can you take it from here? Commented Jul 13, 2024 at 0:12
  • Hi Kamil, thanks for the hint but unfortunately I'm unsure how to execute it. Commented Jul 13, 2024 at 2:06
  • Does path\to\file indicate that the local OS is Windows? It probably does not matter, but please be specific. The remote OS looks like Linux/Unix. Is this right? Commented Jul 13, 2024 at 10:15
  • Yes the local OS is Windows and the remote OS is Linux/Unix. Commented Jul 13, 2024 at 10:51

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.