0

I'm using redis-cli within a bash script, now I want to save the current date in a specific format into a redis specific key. how do I do that? I already tried redis-cli -x SET last-modified $(date +"%D %T") but without success.

Any help will be appreciated!

NNH
  • 265
  • 3
  • 10

1 Answers1

1

Try this

date +"%D %T" | redis-cli -x SET last-modified
OK
redis-cli GET last-modified
"05/30/22 08:32:05\n"

You can see an example in redis-cli help, only relevant output is presented

redis-cli --help
  -x                 Read last argument from STDIN (see example below).

Examples:
  cat /etc/passwd | redis-cli -x set mypasswd
usuario
  • 2,132
  • 1
  • 10
  • 26