Copying some text to a new file is a common operation on Linux. I usually do this by opening the file with ‘vim’, pasting the text in ‘vim’, and then saving the file. I learned a more efficient and quicker way from my advisor during one discussion with him when I show him some results.
Here is the quicker way to copy text to a file.
Then, the most important part, past the text to a new or to-be-overwritten file, say ‘file.txt’:
$ cat > file.txt
The ‘cat’ now is waiting for input from STDIN. We can paste the text to it by ‘Ctrl+Shift+v’.
The last step, press ‘Ctrl+d’ to tell ‘cat’ that we have finished inputting the text.
After this, the text is saved to the new file ‘file.txt’.
I like this method much—it improves the efficiency significantly of this common operation and save much of my time.