Score:-1

why shell discard my string of variable

br flag
[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?

Score:0
in flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.