Skip to main content
deleted 8 characters in body
Source Link

I have log.txt with sample output like these:

...
10-Feb-2022 15:15:14.099 lorem
10-Feb-2022 15:15:15.133 ipsum
10-Feb-2022 15:15:16.233 dolor
...

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

I have figured out how to convert date string to timestamp

date --date='10-Feb-2022 15:15:14.099' +"%s"
Output:
1644480914

My brain still don't get it how to apply that date command to log.txt.

Also How do I pipeline that date command?

printf "10-Feb-2022 15.15.17.012 water" | date --date=<what must i put here?> + "%s"

I expect the output of pipelined command is same, the different is without disturb other column, that is 1644480917 water

I have log.txt with sample output like these:

...
10-Feb-2022 15:15:14.099 lorem
10-Feb-2022 15:15:15.133 ipsum
10-Feb-2022 15:15:16.233 dolor
...

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

I have figured out how to convert date string to timestamp

date --date='10-Feb-2022 15:15:14.099' +"%s"
Output:
1644480914

My brain still don't get it how to apply that date command to log.txt

I have log.txt with sample output like these:

...
10-Feb-2022 15:15:14.099 lorem
10-Feb-2022 15:15:15.133 ipsum
10-Feb-2022 15:15:16.233 dolor
...

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

I have figured out how to convert date string to timestamp

date --date='10-Feb-2022 15:15:14.099' +"%s"
Output:
1644480914

My brain still don't get it how to apply that date command to log.txt.

Also How do I pipeline that date command?

printf "10-Feb-2022 15.15.17.012 water" | date --date=<what must i put here?> + "%s"

I expect the output of pipelined command is same, the different is without disturb other column, that is 1644480917 water

deleted 8 characters in body
Source Link

I have log.txt with sample output like these:

...
10-Feb-2022 15:15:14.099 lorem
10-Feb-2022 15:15:15.133 ipsum
10-Feb-2022 15:15:16.233 dolor
...

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

I have figured out how to convert date string to timestamp

date --date='10-Feb-2022 15:15:14.099' +"%s"
Output:
1644480914

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

But myMy brain still don't get it how to apply that date command withto log.txt

I have log.txt with sample output like these:

...
10-Feb-2022 15:15:14.099 lorem
10-Feb-2022 15:15:15.133 ipsum
10-Feb-2022 15:15:16.233 dolor
...

I have figured out how to convert date string to timestamp

date --date='10-Feb-2022 15:15:14.099' +"%s"
Output:
1644480914

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

But my brain still don't get it how to apply that date command with log.txt

I have log.txt with sample output like these:

...
10-Feb-2022 15:15:14.099 lorem
10-Feb-2022 15:15:15.133 ipsum
10-Feb-2022 15:15:16.233 dolor
...

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

I have figured out how to convert date string to timestamp

date --date='10-Feb-2022 15:15:14.099' +"%s"
Output:
1644480914

My brain still don't get it how to apply that date command to log.txt

Source Link

date string column to timestamp column in a log file

I have log.txt with sample output like these:

...
10-Feb-2022 15:15:14.099 lorem
10-Feb-2022 15:15:15.133 ipsum
10-Feb-2022 15:15:16.233 dolor
...

I have figured out how to convert date string to timestamp

date --date='10-Feb-2022 15:15:14.099' +"%s"
Output:
1644480914

I expect the output of filtered log.txt will be

...
1644480914 lorem
1644480915 ipsum
1644480916 dolor
...

But my brain still don't get it how to apply that date command with log.txt