0

we have logs like this

more log

20/08/02 13:41:39 some text 
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB
20/08/02 13:41:40 some text 
20/08/02 13:41:41 some text 
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2347
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2347
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2347
20/08/02 13:41:42 some text 
20/08/02 13:41:43 some text 
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2347

I want to match only the lines with date

so we do that

echo "$(date +"%Y/%m/%d")"

it gives us

2020/08/02

but when we try to grep the date to log we not get any output

example:

 grep  "$(date +"%Y/%m/%d")" log

what is wrong with my grep syntax

?

expected output

20/08/02 13:41:39 some text 
20/08/02 13:41:40 some text 
20/08/02 13:41:41 some text 
20/08/02 13:41:42 some text 
20/08/02 13:41:43 some text 
0

1 Answer 1

2

The lines you're looking for start with 20/08/02, not with 2020/08/02. Try %y instead of %Y, this will give the last two digits of the year.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.