Hi,
i have a file hello.log which as several line that look like the below
2015-12-07 09:46:56 0:339 120.111.12.12 POST /helloWorld
2015-12-07 09:46:57 0:439 122.111.12.12 POST /helloWorld
....
when i grep expecting to see results like the below.
grep '2015-12-07 09:4' hello.log
I do not see any results when i was expecting to see both the above lines in the output.
Can you tell me if my grep is ignoring the white spaces between the two strings and what should be done to fix this ?
Yoda
December 7, 2015, 12:05pm
2
Try:-
egrep "2015-12-07[ ]+09:4"
RudiC
December 7, 2015, 12:06pm
3
It works exactly as expected and prints the two lines as they are matching... Did you try with wildcards or sequences (e.g. " *")?
Aia
December 7, 2015, 12:29pm
4
grep is not ignoring the white spaces, most likely the white spaces are not matching. i.e. it could be that white spaces are tabs or mix of tab and single spaces and you are using perhaps just spaces or any of those combinations.
It does not print output anything ... that the problem ... i was expecting both the lines to be printed.
---------- Post updated at 12:32 PM ---------- Previous update was at 12:31 PM ----------
This is what i think is happening ... but how will i be able to understand and grep if it has tabs and other white spaces !!
RudiC
December 7, 2015, 12:33pm
6
Try
grep '2015-12-07[[:space:]]*09:4' file
2015-12-07 09:46:56 0:339 120.111.12.12 POST /helloWorld
2015-12-07 09:46:57 0:439 122.111.12.12 POST /helloWorld
1 Like
Does not work ... Not results Found !!
I think it may have tabs aur other whitespace keys .... not sure how can i confirm and get this to work.
---------- Post updated at 12:38 PM ---------- Previous update was at 12:35 PM ----------
Works !! Solved.