English 中文(简体)
利用灰色确定字数(如果在一行有多个字句)
原标题:Determining word count using grep (in cases where there are multiple words in a line)

可否确定使用灰色体显示的某一字数

我尝试了“-c”办法,但这种回报是,特定词的对应线数目在上。

例如,我有档案

某些词和配对 语言和配对 说 明

然后是另一个配对 说 明

“配对器”和“-c”选项在档案中穿透只剩2份。

注:这是对标准不ix的灰色指挥线的用处。

问题回答

<代码>grep -o string file>将退回所有对应的探测事件。 然后,你可以做<条码>grep -o string file , . >-l

我认为,如果使用灰色——i-o string file , wc-l,就应当给你正确的产出,当你做什么——即——在档案中打脚?

You can simply count words (-w) with wc program:

> echo "foo foo" | grep -o "foo" | wc -w
> 2




相关问题
Really strange grep 2.5.1 bug in cat d reading long lines

Recently a peer and I discovered an interesting bug in GNU grep 2.5.1 in which standard input with lines greater than 200,000,000 characters causes grep to fail, even if the pattern is not in one of ...

grep a tab in UNIX

How do I grep tab ( ) in files on the Unix platform?

how to grep a variable in the shell program? [duplicate]

#!/bin/bash for ((var=0; var<20; var++)) do echo " Number is: $(grep Multiple_Frame = echo **$var** 20mrf.txt | wc -l)" >>statisic.txt done This shell program cannot produce correct ...

GREP - finding all occurrences of a string

I am tasked with white labeling an application so that it contains no references to our company, website, etc. The problem I am running into is that I have many different patterns to look for and ...

Grep doesn t work correctly with .as files

Here s the statement I m running: grep -i -H ConfigureControls *.as Note that I m forcing file names with the -H flag. What I get back is: } } trac} } this.chairControls.debug....

热门标签