skip to content
Alvin Lucillo

Delete keys based on search result

/ 1 min read

You can also pass all keys from KEYS command ans transform them into positional arguments to DEL with xargs.

 redis-cli KEYS 'domain*'                          
1) "domain1:key1"
2) "domain2:key3"
3) "domain1:key2"
 redis-cli KEYS 'domain*' | xargs -r redis-cli DEL
(integer) 3
 redis-cli KEYS 'domain*' 
(empty array)