How do I pipe output to date -d "value"?

LeigerGaming

I have a date like "2014-01-30 05:04:27 GMT", and if I run date -d "2014-01-30 05:04:27 GMT", the output is in my server's timezone ("Thu Jan 30 16:04:27 EST 2014").

With the use of grep and cut, I have extracted the date in GMT from a file. However, I am struggling to then convert this into my local time.

For example:

[user@server log]# grep "something" logfile.txt | grep "Succeeded" | cut -f1 -d'['

Output: 2014-01-30 05:04:27 GMT

What can I add on the end, to pass that output to "date -d"?

Attempted:

  • [user@server log]# grep "something" logfile.txt | grep "Succeeded" | cut -f1 -d'[' | date -d
  • [user@server log]# grep "something" logfile.txt | grep "Succeeded" | cut -f1 -d'[' | date
  • [user@server log]# grep "something" logfile.txt | grep "Succeeded" | cut -f1 -d'[' | date -d "$1"
John1024
gmt="$(grep "something" logfile.txt | grep "Succeeded" | cut -f1 -d'[')"
date -d "$gmt"

Or, if you prefer the pipeline format:

grep "something" logfile.txt | grep "Succeeded" | cut -f1 -d'[' | { read gmt ; date -d "$gmt" ; }

The problem is that date does not use stdin. Thus, we have to capture the stdin into a variable (called gmt here) and then supply that on the command line to date.

Sample output from the second approach:

$ echo  "2014-01-30 05:04:27 GMT" | { read gmt ; date -d "$gmt" ; }
Wed Jan 29 21:04:27 PST 2014

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how do I pipe output of a python script into an Rscript?

From Dev

How do I pipe terminal standard output (stdout) to the clipboard?

From Dev

How do I pipe terminal standard output (stdout) to the clipboard?

From Dev

How do I pipe the output of tar through mv?

From Dev

how do I pipe output of a python script into an Rscript?

From Dev

How do I get the output of jq to pipe to curl

From Dev

How do I use pipe to keep the value that is in a child process?

From Dev

How do I get a value after pipe complete?

From Java

How do I recursively grep files in multiple folders? I'm unable to pipe the recursive cat output

From Dev

How can I pipe output of ffmpeg to ffplay?

From Dev

SQL : How do i output date range in SQL Server

From Dev

How do I sort the output of "ls" by last modified - including the date?

From Dev

How do I output just the date in a console application?

From Dev

How do I pipe to a text file the command prompt output from iperf to a file

From Dev

How do I pipe the output of a curl command to an environment variable and use it in another curl command?

From Dev

How do i apply a command to each line in the output from pipe and add all those numbers?

From Dev

How can I redirect `time` output and command output to the same pipe?

From Dev

How do I output a numeric value in Assmbler (GAS)

From Dev

How do I set the output of a function as a variable value in a bash script?

From Dev

How do I set the output of a function as a variable value in a bash script?

From Dev

How do I assign the Output of a command as a Value of a variable?

From Dev

How do I cancel a PIPE operation?

From Dev

How do I pipe HEREDOC to head?

From Dev

How do I pipe into a third process?

From Dev

How do I use subset in a ggplot pipe?

From Dev

How do I pipe HEREDOC to head?

From Dev

How do I write a pipe filter in Rust?

From Dev

How do I convert a decimal year value into a Date in Javascript?

From Dev

How do I add a value of 'date' type to a pytable?

Related Related

  1. 1

    how do I pipe output of a python script into an Rscript?

  2. 2

    How do I pipe terminal standard output (stdout) to the clipboard?

  3. 3

    How do I pipe terminal standard output (stdout) to the clipboard?

  4. 4

    How do I pipe the output of tar through mv?

  5. 5

    how do I pipe output of a python script into an Rscript?

  6. 6

    How do I get the output of jq to pipe to curl

  7. 7

    How do I use pipe to keep the value that is in a child process?

  8. 8

    How do I get a value after pipe complete?

  9. 9

    How do I recursively grep files in multiple folders? I'm unable to pipe the recursive cat output

  10. 10

    How can I pipe output of ffmpeg to ffplay?

  11. 11

    SQL : How do i output date range in SQL Server

  12. 12

    How do I sort the output of "ls" by last modified - including the date?

  13. 13

    How do I output just the date in a console application?

  14. 14

    How do I pipe to a text file the command prompt output from iperf to a file

  15. 15

    How do I pipe the output of a curl command to an environment variable and use it in another curl command?

  16. 16

    How do i apply a command to each line in the output from pipe and add all those numbers?

  17. 17

    How can I redirect `time` output and command output to the same pipe?

  18. 18

    How do I output a numeric value in Assmbler (GAS)

  19. 19

    How do I set the output of a function as a variable value in a bash script?

  20. 20

    How do I set the output of a function as a variable value in a bash script?

  21. 21

    How do I assign the Output of a command as a Value of a variable?

  22. 22

    How do I cancel a PIPE operation?

  23. 23

    How do I pipe HEREDOC to head?

  24. 24

    How do I pipe into a third process?

  25. 25

    How do I use subset in a ggplot pipe?

  26. 26

    How do I pipe HEREDOC to head?

  27. 27

    How do I write a pipe filter in Rust?

  28. 28

    How do I convert a decimal year value into a Date in Javascript?

  29. 29

    How do I add a value of 'date' type to a pytable?

HotTag

Archive