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

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

How can I make redis export just the list values, one in each row?


1 Answer 1


On my laptop redis-cli, using the --raw command-line option produces output with just the plain list values. I.e., without the "1)", "2)", etc. prefixes.

Redis version 6.0.9 added the --raw command-line option to redis-cli, so older versions won't support it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .