开发者

Trying to make a filter with grep

I'm trying to make a filter that capture all the .exe file lines. For example, from this:

[05/Apr/2010:11:00:01 -0300] /~mauro/Lista_conceitos_BD_2004.DOC 200 46080

[05/Apr/2010:11:00:54 -0300] /~lucia/articles/PROPOR96-Rino.pdf 200 153253

[05/Apr/2010:11:01:32 -0300] /~daniel_leite/RenomearTudo/setup.exe 200 1692017

[开发者_开发技巧05/Apr/2010:11:02:12 -0300] /~grv/tutrv/fig23.jpg 200 22821

[05/Apr/2010:11:04:11 -0300] /~lucia/TechRep/NILCTR981-RMartinse

I want to get this:

[05/Apr/2010:11:01:32 -0300] /~daniel_leite/RenomearTudo/setup.exe 200 1692017

I'm trying with grep -w '*.exe' filteredAccessLog > filteredSuccessIMGAccessLog but it is not working at all. If someone could help, I'd be thankful.


The asterisk means *, and the . means "any character". Give this a try:

grep "\.exe" filteredAccessLog > filteredSuccessIMGAccessLog


grep -F .exe filteredAccessLog > filteredSuccessIMGAccessLog


That asterisk may not mean what you may think it means. In regular expressions, asterisk means 0 or more repetitions of the previous character or group.


Just leave out the asterisk:

grep -w '.exe' filteredAccessLog > filteredSuccessIMGAccessLog
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜