I have a string with tab delimited data that looks like:
h1 h2 a1 b1 a2 b2
I produced it with Notepad on Windows. I created tab delimited data, ensuring that tabs and not spaces are used.
I connect to a Linux server via SSH using PuTTY.
I would like to write the file to
/tmp/test.txt and preserve the tabs.
So I run
cat <<EOF >/tmp/test.txt. I copy the text from Notepad and paste it into the putty session. Then I enter
However, that produces a file without tabs having the contents of:
h1h2 a1b1 a2b2
I've found that this works:
sed 's/\\t/\t/g' > /tmp/test.txt << EOF h1\th2 a1\tb1 a2\tb2 EOF
However, it required that I change my input string to use '\t' instead of actual tabs. What is a more elegant/simple solution that allows me to take a string literal as-is from Windows and write it into a file on the remote Linux machine?
I am SSHed into a Linux server from Windows via putty. The server is:
- Distribution: Red Hat Enterprise Linux Server release 6.6 (Santiago)
- Bash version: 4.1.2(1)-release (x86_64-redhat-linux-gnu)
- cat: coreutils-8.4-37.0.1.el6.x86_64