Windows批处理命令忽略某些文件行?
我将 cvs diff 的输出重定向到 log.txt 文件。
C:\Temp> cvs diff -b -B -r 1.5 -r 1.6 Project\src\Sample.java > log.txt
执行上述命令后,log.txt
文件生成的内容如下:
Index: project/src/Sample.java
===================================================================
RCS file: \repobase/src/Sample.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -r1.5 -r1.6
78a79,82
> public java.lang.Class getJavaClass() {
> return Sample.class;
> }
>
92c96
< return Demo.getparentClass(this.getClass());
---
> return MyClass.clazz;
该文件中以 <
或 > 不是必需的。我想忽略所有这些行,只是将最少的剩余内容推入
log.txt
文件中。我如何通过 Windows 命令行执行此操作?
I am redirecting the output of a cvs diff onto a log.txt file.
C:\Temp> cvs diff -b -B -r 1.5 -r 1.6 Project\src\Sample.java > log.txt
The generated content of the log.txt
file upon executing the above command is like this :
Index: project/src/Sample.java
===================================================================
RCS file: \repobase/src/Sample.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -r1.5 -r1.6
78a79,82
> public java.lang.Class getJavaClass() {
> return Sample.class;
> }
>
92c96
< return Demo.getparentClass(this.getClass());
---
> return MyClass.clazz;
All lines of this file that start with <
or >
are not necessary. I want to ignore all such lines only to push in the minimal rest into the log.txt
file. How can I do this via windows command line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许 cvs diff --brief 选项会给你你想要的。
如果没有,那么您可以将 diff 输出通过管道传输到 FINDSDTR 并让它过滤行
/v 选项表示打印不包含任何字符串的行
/b 选项表示匹配从每行开头开始的搜索字符串
/l表示文字搜索字符串(与正则表达式相对)
搜索字符串在每个空格处分割,因此“< >”实际上是 2 个搜索字符串。
有关 FINDSTR 的更多帮助,请使用“FINDSTR /?”。
如需其他帮助,请参阅Windows FINDSTR 命令有哪些未记录的功能和限制?
Perhaps the cvs diff --brief option will give you what you want.
If not, then you can pipe the diff output to FINDSDTR and let it filter the lines
/v option means print lines that don't contain any of the strings
/b option means match the search string starting at the beginning of each line
/l means literal search string (as opposed to a regular expression)
Search string is split at each space, so "< >" is really 2 search strings.
For more more help on FINDSTR use `FINDSTR /?'.
For additional help see What are the undocumented features and limitations of the Windows FINDSTR command?