Search code examples
bashrediscontrol-characters

How to use a control character in a redis-cli argument?


What I am trying to execute from my bash script:

redis-cli srem myset "abc\x06def"

\x06 part seems to be ignored.

OS is Ubuntu 14.04 LTS and LANG=en_US.UTF-8, if these have anything to do with the problem.


Solution

  • With bash I suggest:

    redis-cli srem myset "abc"$'\x06'"def"
    

    For checking the existence:

    echo "abc"$'\x06'"def" | hexdump -C
    

    Output:

    00000000  61 62 63 06 64 65 66 0a                           |abc.def.|
    00000008