I have an issue where ^M
characters are being inserted into a script file. I have a Bash script:
#!/bin/bash
# Do something
echo "hello world"
Using PowerCLI I copy the script file from Windows to a Ubuntu virtual machine:
Copy-VMGuestFile -Source "C:\test.sh" -Destination /tmp/test.sh -LocalToGuest -GuestUser root -GuestPassword p@ssword -VM VM001
After copying, when opening the file with vi
the format shown is:
#!/bin/bash^M
^M
# Do something^M
echo "hello world"^M
Is there a way to stop ^M
being added when copying the file? I can replace the characters using sed
, but this is not a clean solution.