"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.
2008-03-27
Unix Equivalent of DOS COPY CON
This is an answer to a question I got by e-mail.
Subscribe to:
Post Comments (Atom)
2 comments:
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>
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
Post a Comment