skip to Main Content

In my redis database, I’m trying to delete a series of keys that start with:

EPOCH_vgsOwnedVehs_

I have tried the following:

redis-cli -h 127.0.0.1 -p myport -a mypassword --scan --pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli unlink

and

redis-cli -h 127.0.0.1 -p myport -a mypassword --scan --pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli -h 127.0.0.1 -p myport -a mypassword unlink

But, I get the following error message:

'xargs' is not recognized as an internal or external command, operable program or batch file.

Could anyone help as to why xargs won’t work in this case? I see that same syntax above being mentioned quite a few times here and seems to work for others…

EDIT: I forgot to mention that when I run the first half of the line before the pipe, it does return all the keys that match the criteria.

2

Answers


  1. The following should do the work; (added an example print-out)

    redis-cli -h 127.0.0.1 -p 6379 -a mypass –scan –pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli -h 127.0.0.1 -p 6379 -a mypass unlink

    127.0.0.1:6379> config set requirepass mypass
    OK
    127.0.0.1:6379> auth mypass
    OK
    127.0.0.1:6379> set EPOCH_vgsOwnedVehs_a a
    OK
    127.0.0.1:6379> set EPOCH_vgsOwnedVehs_b a
    OK
    127.0.0.1:6379> set EPOCH_vgsOwnedVehs_c a
    OK
    127.0.0.1:6379> set EPOCH_vgsOwnedVehs_d a
    OK
    127.0.0.1:6379>
    
    redis-cli -h 127.0.0.1 -p 6379 -a mypass --scan --pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli -h 127.0.0.1 -p 6379 -a mypass unlink
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    (integer) 4
    
    
    127.0.0.1:6379> auth mypass
    OK
    127.0.0.1:6379> exists EPOCH_vgsOwnedVehs_a
    (integer) 0
    
    Login or Signup to reply.
  2. xargs is a common Linux utility and the message you are seeing indicates you are using Windows. You have a couple of choices here to get this working – you can find a Windows alternative of xargs, use Cygwin, use Powershell, etc.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search