The below code does not create a file inside the container.
lxc launch ubuntu: test
lxc exec test -- "echo test > /home/ubuntu/file.sh"
lxc exec test -- ls /home/ubuntu
That's because there is no command called "echo test > /home/ubuntu/file.sh" in your container.
I suspect you want:
lxc exec test -- sh -c "echo test > /home/ubuntu/file.sh"
Most helpful comment
That's because there is no command called "echo test > /home/ubuntu/file.sh" in your container.
I suspect you want: