Saving Redis Query Output to a File

Using redis-cli, I connected to a specific server:

redis-cli -h 10.1.xx.xx

And select 1

Then just to get a list of key features:

KEYS data_column*

This will print a list of the values ​​of this column on the command line. However, like many other values, I want to save the query output to a file.

In general, using > file_name after running the command. But in this case it does not work, as on the redis server, although from the command line. How to save such a query result?

+8
redis redis-cli
source share
4 answers

Just use:

 ./redis-cli -h 10.1.xx.xx -n 1 keys 'data_column*' >file.txt 
+18
source share

echo "keys data_column *" | redis-cli -h 10.1.xx.xx -p xx> file.txt

+4
source share

Use the following command line to export all keys to a file.

./redis-cli -h XX -p YY KEYS "keyname *" >> filedata.txt

XX β†’ hostname

YY β†’ password

0
source share

-p means no password. this is the port. -a means password. shortcut -a uth

Use the command line below to export all keys to a file.

 ./redis-cli -h XX -p YY KEYS "keyname*" >> filedata.txt 

XX β†’ hostname

YY β†’ password

0
source share

All Articles