Unix Equivalent of DOS COPY CON

This is an answer to a question I got by e-mail.

“A lot of times I need to create a quick text file, like a script (like I used to create Batch files in DOS/Windows). I used to use COPY CON for this. How can I do this in Unix?”

This is just as easy in Unix. Instead of COPY CON filename, use cat >filename. As before enter the text for the file. Then close the file by hitting enter one more time and entering control-D.

Remember, if you are creating a shell script, make the file executable with chmod +x filename.

Also, to execute the script, remember to include the path to the script, even if you are in the same directory as the script, like this ./scriptname.

Be Sociable, Share!

2 thoughts on “Unix Equivalent of DOS COPY CON

  1. Hello,
    Thanks for the tip. Is there a Unix equivalent of COPY CON: going the other way? For example,
    DOS<copy con: newfile.txt
    … type or paste something followed by ctrl-z …
    ^Z
    DOS>

  2. cat >somefile.txt
    Enter some text
    ^D

    You just cat with the output going to a file and press control-D when you are done.

    -A

Comments are closed.