What does <<< mean>output-filename)

2019-08-11 23:57发布

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?

标签: bash socat
3条回答
The star\"
2楼-- · 2019-08-12 00:35

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.

查看更多
欢心
3楼-- · 2019-08-12 00:47

A posix shell version would be:

echo "show servers state" | socat /tmp/haproxy - > /var/state/haproxy/global

<<< is a bashism to put a string on stdin

查看更多
Viruses.
4楼-- · 2019-08-12 00:54

The man pages of the socat command and bash may help (Note that <<< is a bash feature)

Try:

man socat
man bash
# Type the following when the bash man page is open
# it will point you right to the explanation of <<<
/<<<  
查看更多
登录 后发表回答