I connect to a lot of Linux servers with ssh and run a health check script on each, wanted to save myself 2 secs per server when doing so. So instead of normally creating the script file:
cat > test.sh
+
right-click paste(whole script file -copied from notepad)
+
ctrl+c
I right click paste: here doc with whole script(copied form notepad):
cat <<'EOF' > test.sh
#!/bin/bash
commands..
commands..
EOF
Aprox 50% times script inside gets corrupted when pasted like this. Corruption occurs on random line/lines(part of line is missing, some characters are missing etc.) which results in syntax errors when script is run, other 50% times script is pasted OK and can be run OK.
Problem is definitely not in the script itself. When it is copied cat > filename way, it works 100%. Notepad where the text is copied from uses UNIX - LF EOL conv. but this also happens when switched to windows CRLF type. Script has no tabs inside, just whitespaces also limitString has no leading whitespace before itself
Script is 430 lines long, could this be a problem? I have been using same syntax for some time in some other bash scripts or directly in terminal but never experienced such behavior.
Anyone has ideas what might be causing this? Or possible workaround?