在下面的例子中,为什么我在字符串的末尾多了一个斜杠\。
[root@server src]# echo 'testme one more word new line' | ./redis-cli -x set mytest
OK
[root@server src]# ./redis-cli
redis> get mytest
"testme one more word new line\"
在上面的例子中,我不想要“line\”中的\。原来的 echo 语句中没有。
最佳答案
我得到的不是反斜杠,而是换行符(反斜杠+n)。
这是由“echo”命令添加的。您可以使用 echo -n
来避免额外的换行:
$ echo -n 'testme one more word new line' | ./src/redis-cli -x set mytest
OK
$ ./src/redis-cli get mytest
"testme one more word new line"
关于redis - redis 输出中的额外斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8091582/