Questions tagged [here-document]
234 questions
11
votes
2 answers
How to indent an heredoc inside an heredoc the right way?
The following codepiece is a script used to install Apache. I run this script in-place when executing it from the heredoc block that wraps it (APACHE).
Note that inside this APACHE heredoc, I have an internal heredoc (MOD_REWRITE), which I can…
user149572
2
votes
1 answer
Why is there a bash keyword before some heredocs?
In some heredocs, you see the keyword bash before the opener (<<), the name, and the File descriptor. For example:
bash /dev/fd/10 10<<'SES'
Why is the Bash there? I mean, we already work in Bash, and it's not like cat used to display the text and…
user149572
1
vote
2 answers
Here document and input redirection with -
What does the following command do? In particular I don't understand the role of - in input redirection.
cat <<-EOF | command $argument
first option
second option
EOF
Is it mandatory to have the - in the input redirection?

Vombat
- 12,884
0
votes
2 answers
How to pass a script-file to sed as a heredoc?
This converts 'a' to 'A'.
sed 's/a/A/g' <(echo "foobar")
foobAr
This supplies the commands necessary to make each vowel upper-case:
$ cat << EOF
s/a/A/g
s/e/E/g
s/i/I/g
s/o/O/g
s/u/U/g
EOF
What I'm trying to do, is to extend the first example so…

Erwann
- 677
0
votes
1 answer
What is the hyphen (‐) used for in this command tee <<-'EOF'?
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.

lamplet
- 3
0
votes
2 answers
Why are heredocs "dependent" on file descriptors?
I publish this question with an answer so to clarify to new users, why some heredoc syntax would deal with file descriptors; I myself had some trouble understanding it at first.
See for example:
bash << EOF0
command1
<< E0F1
…
user149572
0
votes
3 answers
Where do people use the "Here document" on UNIX systems?
Where do people use the "Here document" on UNIX systems?
Where is it used in reality?

LoukiosValentine79
- 1,499
-1
votes
1 answer
What is the meaning of the 3 3 in bash /dev/fd/3 3<< 'EOF'
There is a Unix code I saw and don't have enough background to fully dechipher:
bash /dev/fd/3 3<< 'EOF'
What is the meaning of 3 3 above? I know what is an heredoc, what is Bash, a device, and fd, but I don't know what is 3 space 3... When I…
user149572