How to delete keys prefixed with hex/special characters

182 views
Skip to first unread message

Joe Leogrande

unread,
Nov 20, 2019, 1:30:07 PM11/20/19
to Redis DB
Hi All,

I have a situation where I need to delete some old keys which look similar to below. When I attempt the delete the keys, the delete does not work.  I think I need to somehow escape the leading characters in the keys but I am not sure how to do this.

Key example:
\xAC\xED\x00\x05ur\x00\x02[B\xAC\xF3\x17\xF8\x06\x08T\xE0\x02\x00\x00xp\x00\x00\x00H{\x0A "Mode": "transit",\x0A "TransitMode": "subway",\x0A "TravelTime": 1892\x0A}

delete example:

/opt/rh/rh-redis32/root/usr/bin/redis-cli -h redis-host -p 6379 -a password --scan --pattern "*GEO_TTS*" | xargs /opt/rh/rh-redis32/root/usr/bin/redis-cli -a password del

response:
(integer) 0

Itamar Haber

unread,
Nov 20, 2019, 2:10:38 PM11/20/19
to redi...@googlegroups.com
Hello Joe,

The issue is with xargs' handling of backslashes - this is even documented on its man page. I was able to hack my way around it (on macOS 10.14/15) with something like the following, but YMMV depending on the OS:

redis-cli --scan --pattern "*GEO_TTS*" | sed 's/\\/\\\\/' | xargs -L 1 redis-cli -a password DEL

Cheers,

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/d968a4f9-b56c-4a3c-b0a5-17d9d3940c1a%40googlegroups.com.


--

Itamar Haber
Technicalist Evangely

Phone: +972.54.567.9692

Redis Labs

Reply all
Reply to author
Forward
0 new messages