Alucard
Alucard

Reputation: 17278

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.

Upvotes: 0

Views: 186

Answers (4)

houbysoft
houbysoft

Reputation: 33392

grep -F .exe filteredAccessLog > filteredSuccessIMGAccessLog

Upvotes: 5

Curtis
Curtis

Reputation: 4031

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

grep "\.exe" filteredAccessLog > filteredSuccessIMGAccessLog

Upvotes: 6

Dennis Williamson
Dennis Williamson

Reputation: 359875

Just leave out the asterisk:

grep -w '.exe' filteredAccessLog > filteredSuccessIMGAccessLog

Upvotes: 1

ninjalj
ninjalj

Reputation: 43688

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.

Upvotes: 2

Related Questions