Windows批处理命令忽略某些文件行?

发布于 2025-01-02 00:16:16 字数 786 浏览 1 评论 0原文

我将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百变从容 2025-01-09 00:16:16

也许 cvs diff --brief 选项会给你你想要的。

如果没有,那么您可以将 diff 输出通过管道传输到 FINDSDTR 并让它过滤行

cvs diff -b -B -r 1.5 -r 1.6 Project\src\Sample.java | findstr /vbl "< >" > log.txt

/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

cvs diff -b -B -r 1.5 -r 1.6 Project\src\Sample.java | findstr /vbl "< >" > log.txt

/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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文