So, should we be spreading this trick around, if it's likely to stop working? This is one of the weirdest Windows workaraounds I have encountered in years. Kevin Kuphal Kevin Kuphal 9, 1 1 gold badge 33 33 silver badges 41 41 bronze badges. Other than that, standard cmd. Open command prompt and use the move command to rename the file.
Mark Mark 1 1 gold badge 7 7 silver badges 12 12 bronze badges. John Gietzen John Gietzen 5 5 silver badges 11 11 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. What is "excecise"? Do you mean exercise?
You could also use: echo. Craig Craig 51 1 1 silver badge 1 1 bronze badge. Nomad Nomad 59 1 1 silver badge 1 1 bronze badge. This could be very wrong if abc was in the path and was a convenience function for formatting all the drives except the installation directory.
Lucky Lucky I believe the reason your trick works here is because all of the output is going to the error handle but you're only directing STDOUT to the file.
You should see the error message inside that file now. The first one will not result in an empty file. Also copy nul filename works without redirecting more obvious solution.
EKons EKons 1 1 gold badge 22 22 silver badges 27 27 bronze badges. At least it is not an obscure solution, like many of the other answers. I read many threads but it is not the shortest way. Why does it work? This copy NUL file which contain 0 bytes. Amado Saladino Amado Saladino 1, 17 17 silver badges 20 20 bronze badges.
How does this work? Is con some reserved thingamabob? Please respond by editing your answer , not here in comments without "Edit:", "Update:", or similar - the answer should appear as if it was written today. As I wrote, dun type anything, just press F6 — Amado Saladino. Add the folder to the PATH environment variable. You can use touch to create files. Pranay Kumar Pranay Kumar 1, 11 11 silver badges 13 13 bronze badges.
Rain Rain 2, 1 1 gold badge 13 13 silver badges 29 29 bronze badges. Good point. I forgot the stderr redirection in my own answer. I have edited said answer accordingly. GadBro GadBro 31 1 1 bronze badge.
I didn't find any commands other than this that could create a empty file. Note: You have to be in the directory you wish to create the file. I am not sure about why it does so, but I guess that you should do "echo on" after entering the above command. Re "I didn't find any commands other than this that could create a empty file. This actually works in DOSBox, unlike many of the other solutions here. Trying to echo nothing into a file adds a line break, using NUL seems to fill up a file endlessly, and if you try executing a nonexistent command, DOSBox will redirects the actual OS response on that to the text file.
I have just tried in Windows: copy con file. And it worked for me. For Ubuntu, usually I am creating a file using the vi command vi file. The question said "The command needs to run from a script, so keystrokes cannot be used.
First create your file so that it exists: echo. This thread is locked. You can follow the question or vote as helpful, but you cannot reply to this thread. I have the same question 0. Report abuse. Details required :.
Cancel Submit. Michael Gall Microsoft Agent. Hi, To isolate your concern, was there an update that was made on your computer prior to this issue? We look forward to your response. How satisfied are you with this reply? Thanks for your feedback, it helps us improve the site.
In reply to Michael Gall's post on January 25, Prior to what issue? The following fundamental rules enable applications to create and process valid names for files and directories, regardless of the file system:.
Use a period to separate the base file name from the extension in the name of a directory or file. The backslash divides the file name from the path to it, and one directory name from another directory name in a path. You cannot use a backslash in the name for the actual file or directory because it is a reserved character that separates the names into components.
Do not assume case sensitivity. For more information, see CreateFile. Volume designators drive letters are similarly case-insensitive. Use any character in the current code page for a name, including Unicode characters and characters in the extended character set — , except for the following:. Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.
Use a period as a directory component in a path to represent the current directory, for example ". For more information, see Paths. Use two consecutive periods.. Also avoid these names followed immediately by an extension; for example, NUL. For more information, see Namespaces. Do not end a file or directory name with a space or a period.
Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name.
For example, ". When you create a long file name, Windows may also create a short 8. This 8. Not all file systems follow the tilde substitution convention, and systems can be configured to disable 8. Therefore, do not make the assumption that the 8.
0コメント