Sample Header Ad - 728x90

How to use redis-cli to export the values of a list only?

1 vote
1 answer
1243 views
I am trying to export all values of a redis list using redis-cli as a list of strings in shell scripts. However, there are some unwanted text that I couldn't get rid of. For the following list q1: redis:6379> 5 lpush q1 "{\"id\":1}" (integer) 1 (integer) 2 (integer) 3 (integer) 4 (integer) 5 redis:6379> If I export it directly using LRANGE, the result has a row number and a parenthesis at the beginning of each line (which needs to be removed). :/# redis-cli -h redis LRANGE q1 0 -1 1) "{\"id\":1}" 2) "{\"id\":1}" 3) "{\"id\":1}" 4) "{\"id\":1}" 5) "{\"id\":1}" If I use redis-cli --csv, there is a comma between values (that needs to be removed): :/# redis-cli -h redis --csv LRANGE q1 0 -1 "{\"id\":1}","{\"id\":1}","{\"id\":1}","{\"id\":1}","{\"id\":1}" *How can I make redis export just the list values, one in each row?*
Asked by tinlyx (1072 rep)
Jul 1, 2023, 03:53 PM
Last activity: Jul 2, 2023, 03:47 PM