[root@localhost monitor]# echo "config get *" | redis-cli -a 123456a? 
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) "123456a?"
  5) "masterauth"

返回结果有Warning:,影响取值

参考链接
https://blog.csdn.net/weixin_34253126/article/details/92384670

结果如下

[root@localhost monitor]# echo "config get *" | redis-cli -a 123456a? 2>/dev//null 
  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) "123456a?"

原因是

warning 这串输出并不是普通输出,shell的标准输出包含两种,1(标准输出)2(标准错误)我们的命令,即包含1也包含2,2即是我们想要去除的提示。

解决办法将标准错误去除即可,如图,加了2>/dev/null,将标准错误丢弃即可

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2021-09-01
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-02-08
猜你喜欢
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2021-08-01
  • 2022-02-08
  • 2021-07-10
相关资源
相似解决方案