Search code examples
bashsocat

What does <<< mean in bash (ie. in socat ... <<<"string" >output-filename)


I am trying to understand a codebase where I see a line like below: socat /tmp/haproxy - <<< "show servers state" > /var/state/haproxy/global

What is socat doing here? What does <<< mean?


Solution

  • The socat command creates a bidirectional pipe between the file /tmp/haproxy and stdin which is expressed by passing - to socat.

    In fact it appends stdin to /tmp/haproxy and writes the resulting output to /var/state/haproxy/global

    <<< is a bash feature, a so called here string. It passes the string "show server state" as stdin to socat.