I saw the following command:
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
}
EOF
What is the hyphen (‐) used for? It works fine even i remove the hyphen.
I saw the following command:
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
}
EOF
What is the hyphen (‐) used for? It works fine even i remove the hyphen.
The hyphen/dash is used for telling the shell to remove any leading tab character from the here-document. This is documented by POSIX as part of the here-document redirection:
If the redirection operator is
<<-
, all leading<tab>
characters shall be stripped from input lines and the line containing the trailing delimiter. [...]
The feature allows for creating slightly prettier scripts:
while some-condition; do
some-command <<-END_INPUT
some data
goes here
END_INPUT
done
(where each line in the here-document and the line containing the END_INPUT
delimiter are indented using tabs), as opposed to
while some-condition; do
some-command <<END_INPUT
some data
goes here
END_INPUT
done