-1
[root@es01 ~]# redis-cli  -h IP_ADDRESS -p 6380 -a admin info 2>/dev/null|grep config_file|cut -d: -f2
/opt/redis/7.0.5/cluster/redis-6380.conf

[root@es01 ~]# cat $(redis-cli  -h IP_ADDRESS -p 6380 -a admin info 2>/dev/null|grep config_file|cut -d: -f2)

: No such file or directoryer/redis-6380.conf

anybody can help me?

Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26
redliquid
  • 1
  • 1

1 Answers1

0

redis-cli outputs everything with Windows/DOS line endings (i.e. the line ending is \r\n instead of \n). Because of this, the second line would actually try to output the following file:

/opt/redis/7.0.5/cluster/redis-6380.conf\r

which does not exist. Additionally, when printing the error message, the carriage return character at the end pushes the cursor to the beginning of the line, and printing the rest of the error message continues from the beginning. So

cat: /opt/redis/7.0.5/cluster/redis-6380.conf\r: No such file or directory

becomes

: No such file or directoryer/redis-6380.conf

You need to remove the \r character from the output like this:

cat $(redis-cli  -h IP_ADDRESS -p 6380 -a admin info 2>/dev/null|grep config_file|cut -d: -f2|tr -d $'\r')

As a side note, when an error message begins with a colon, there is always a lurking carriage return character somewhere.

Lacek
  • 7,233
  • 24
  • 28