Questions tagged [heredoc]

A here document is a special-purpose code block. It uses a form of I/O redirection to feed a command list to an interactive program or a command, such as ftp, cat, or the ex text editor.

Filter by
Sorted by
Tagged with
1 vote
1 answer
208 views

HEREDOC in Dockerfile produces no output

I have this command that I am trying to run in a Dockerfile and it is producing no output to the file: FROM alpine:3.19 as base RUN <<-EOF > /root/.npmrc registry=https://\${...
Christian Bongiorno's user avatar
0 votes
1 answer
435 views

bash heredoc and code block

Script has to log everyting in it to output and to log file Like this it works OK: #!/usr/bin/env bash some_command_1 (( echo "Some text (in parenthness too)" echo "Another text ...
Someone's user avatar
  • 169
1 vote
1 answer
1k views

sudo followed by another command in ssh heredoc not working

This is my script: #!/bin/sh echo "I'm local" ssh -t -t remote.server << 'EOF' sudo echo "I'm remote and sudo" echo "I'm remote but not sudo" exit EOF This simply doesn't work, ...
akai's user avatar
  • 113
0 votes
1 answer
753 views

Copy-paste heredocument into Bash converts tabs into dots

I use Windows 10 home (build 16299.248) and I'm SSHing into a remote Ubuntu 16.04 machine with various SSH clients (like Putty/MobaXterm). I copy-paste the following code from my personal GitHub ...
Arcticooling's user avatar
0 votes
1 answer
79 views

Use two here-documents on one line

Are two here-documents allowed to be used on one line, like in the example below? I was not able to find the documentation and cannot make the example work as expected - seeing output of both echo ...
dabest1's user avatar
  • 252
0 votes
2 answers
569 views

How to pass variables from one vm to another vm using bash script

What is the proper way to pass variable from one machine to another machine via bash script? In the below code I am trying to get the input from user and want to pass the same to remote machine, but ...
loganathan's user avatar
1 vote
1 answer
269 views

How do you embed strings within the comments within a heredoc?

This doesn't work, the comment doesn't contain the IP_ADDR string SSH_UN='user' IP_ADDR='192.168.1.101' cat <<"EOF" >> .ssh/config # VirtualBox (VB) on user's laptop at $IP_ADDR Host ...
hobs's user avatar
  • 161
38 votes
3 answers
33k views

How do you escape characters in heredoc?

I'm working with a bash script trying to stop it from attempting to replace variables inside my heredoc. How do set a heredoc to either A) escape the variable names instead of parsing them or B) ...
Xeoncross's user avatar
  • 4,539