grep for windows [英] Grep for windows
问题描述
apple
orange
banana
和 New.txt
包含
苹果
橙色
香蕉
葡萄
柠檬
我可以访问添加到 New.txt
使用 grep
命令。
grep -Fxvf Old.txt新建。 txt> difference.txt
现在, difference.txt
包含
葡萄
柠檬
在Windows中,我试过了
findstr /rvc:Old.txt New.txt > difference.txt
查找差异,但它追加 Old.txt的内容
也是。如何在Windows中编写相应的命令?
您可以使用 DOS
findstr
使用以下标记: -
/ v:仅打印不包含匹配的行。
/ g:file:从指定文件中获取搜索字符串。
该命令可能类似于: - $ /
C:\Users\dude\Desktop> findstr / v /g:Old.txt New.txt> difference.txt
现在使用类型
命令检查文件输出;相当于在 Linux 中的
cat
,我们看到: -
C:\Users\dude\Desktop>类型difference.txt
葡萄
柠檬
Old.txt
contains
apple
orange
banana
And New.txt
contains
apple
orange
banana
grape
lemon
I can access new contents which are added to New.txt
using grep
command.
grep -Fxvf Old.txt New.txt > difference.txt
Now, difference.txt
contains
grape
lemon
In Windows, I have tried
findstr /rvc:Old.txt New.txt > difference.txt
to find the difference but it append contents of Old.txt
too. How can I write equivalent command in Windows?
You can use DOS
findstr
with the following flags:-
/v : Prints only lines that do not contain a match.
/g: file : Gets search strings from the specified file.
The command would be something like:-
C:\Users\dude\Desktop>findstr /v /g:Old.txt New.txt >difference.txt
Now checking the file output using the type
command; equivalent to cat
in Linux
, we see :-
C:\Users\dude\Desktop>type difference.txt
grape
lemon
这篇关于grep for windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!