【发布时间】:2017-07-10 15:15:18
【问题描述】:
我正在尝试计算 the answer here 之后的文件中的行数,例如使用find /C,但我在控制台中看到的只是:
find: '/C': No such file or directory
find: 'A': No such file or directory
我有一个简单的“TEST.txt”文件,其中包含三个 As 和三个 B,都在新行中:
$ type TEST.txt
A
A
A
B
B
B
findstr 似乎可以工作,但它不能返回计数:
$ type TEST.txt | findstr "A"
A
A
A
查找不起作用:
$ type TEST.txt | find "A"
find: 'A': No such file or directory
我错过了什么?
PS:来自1 的整个示例也无法正常工作:
$ findstr /R /N "^" TEST.txt | find /C ":"
find: '/C': No such file or directory
find: ':': No such file or directory
编辑:
因为了解正在发生的事情可能很重要:我使用的是ConEmu terminal。
【问题讨论】:
-
您是从
cmd.exe还是powershell.exe调用find? -
TEST.txt 是现有文件吗?你的确切命令
findstr /R /N "^" TEST.txt | find /C ":"对我有用,在我计算“A”出现次数的文件上。 -
顺便说一句,我用过
cmd.exe。他的错误看起来像是 UNIX 会返回的。powershell.exe将返回FIND:Parameter format not correct,因为语法不同。 -
据我了解,我使用的是
cmd.exe(FreeCommander XE 中的命令/cmd {Shells::cmd (Admin)})... -
而 TEST.txt 是一个现有文件...
findstr /R /N "^" TEST.txt | find /C ":"仍然为我返回find: '/C': No such file or directory和find: ':': No such file or directory。