我想搜索在Unix的精确字纹的出现次数,司令部的Unix计算特定字词
例子:log.txt文件包含以下内容:
aaa (only this 'aaa' pattern shhold be counted)
bbb
cccaaa ---> this should not be counted in grep output
ccc_aaa --> this should not be counted in grep output
ccc-aaa --> this should not be counted in grep output
ccc.aaa ---> this should not be counted in grep output
我使用以下代码 -
count=$?
count=$(grep -c -w aaa $ZZZ\Log.txt)
输出。这里应该==> 1,但即时得到4作为输出,我认为,事情是这样丢失,可以在任何一个可以帮助我在这吗?
如果要匹配* only * aaa,请使用^ aaa $作为模式。 – 2013-04-04 06:51:26
Squiguy,Kelvin:非常感谢您的答复 – 2013-04-04 08:01:00