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.

share and enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Fark
  • Reddit
  • Slashdot
  • StumbleUpon
  • Twitter

2 comments to Unix Equivalent of DOS COPY CON

  • pd

    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>

  • Andrew Ault

    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

Leave a Reply

  

  

  


*

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>