[英]How to write NUL to all log files in a folder using windows command line
I have multiple log files that start as ABC_.log in a windows environment. 我有多个在Windows环境中以ABC_.log开头的日志文件。 I want to clean that file (like writing /dev/null to file in linux). 我想清理该文件(例如在Linux中将/ dev / null写入文件)。 I need to do it through command line. 我需要通过命令行来完成。
What I tried: 我试过的
cmd:$ break > ABC_*.log
and 和
cmd:$ type NUL > ABC_*.log
Error: 错误:
The filename, directory name, or volume label syntax is incorrect
this can't be done via wildcard (not possible to redirect to more than one file at a time). 无法通过通配符完成此操作(无法一次重定向到多个文件)。 Use a for
loop to process each file on it's own: 使用for
循环自行处理每个文件:
for %%a in (ABC_*.log) do (
break>"%%a"
)
or directly on command line: 或直接在命令行上:
for %a in (ABC_*.log) do break>"%a"
The easiest way to empty a file in UNIX/Linux: 在UNIX / Linux中清空文件的最简单方法是:
rm <filename>
touch <filename>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.