Is there a way around this? Is it possible to do a Null on ALL. If that is not possible if I could read the unknownfilename. Seem like a long way of doing something simple though.
Clearing all log files in the directory should do the job. Not quite sure why you would want to clear the contents of a log file. Isn't the purpose of a log file to capture relevant information that you can go back and look at another day? If you really want to clear the contents of all the log files in a directory. Code: [Select]. Thanks I'll give that a go later. The reason I want to clear the logs is because I'm trying to capture a line in it and get it to send an email alert.
I can only manage to capture the first line, so I am going to get the log file cleared after every email is sent. Active Oldest Votes. DannySmurf's solution actually does create an empty file -- a newline goes to stdout, nothing goes to stderr directed into the new file.
Still your answer is better then accepted solution, cause your file will be really empty. Warning: yes the question was on how to create an empty file, however usually you want to "make sure the file exists". If you are used to Unix' touch command, this might not at all be what you expect. I couldn't find any information on CON , aside from that linked in this answer.
Could someone share some light reading? Show 4 more comments. TheSmurf TheSmurf 15k 2 2 gold badges 38 38 silver badges 48 48 bronze badges. This echoes a newline to stdout, though To merge ephemient's answer and this one, you could do: "echo. Why is. Reegan If you used echo 2 without the.
Show 5 more comments. Kevin K 9, 2 2 gold badges 34 34 silver badges 59 59 bronze badges. Anonymous Anonymous.
You are correct. Short and easy. A few other solutions here do not create a new file of zero bytes! This should have been the accepted answer.
About as clean and simple as it gets. Community Bot 1 1 1 silver badge. It's type nul AndriyM thanks you're right I made the edit! Didn't notice because interestingly enough it works with the wrong one. Show 2 more comments. Johannes Johannes 3 3 silver badges 2 2 bronze badges. I'm stuck on Windows CE, and this is the only answer that creates and empty file! The other approaches either add a blank line or simply don't work It's also interesting how this answer from has comments spaced from each other by several years.
A slowwwww conversation! The only problem with this solution is that if there is a file called CD no extension in the current directory, and you type CD. Come for the solution, stay for everything else.
Welcome to our community! How can I create an empty text file through a Batch file? What would the command or commands be to create an empty text file? Most Valuable Expert The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions.
Join our community to see this answer! Unlock 1 Answer and 8 Comments. Andrew Hancock - VMware vExpert. See if this solution works for you by signing up for a 7 day free trial. What do I get with a subscription?
0コメント