heredoc Questions
15
Solved
I have this multi-line string (quotes included):
abc'asdf"
$(dont-execute-this)
foo"bar"''
How would I assign it to a variable using a heredoc in Bash?
I need to preserve newlines.
I don't wan...
13
Solved
I needed to write a script to enter multi-line input to a program (psql).
After a bit of googling, I found the following syntax works:
cat << EOF | psql ---params
BEGIN;
`pg_dump ----somet...
18
Solved
In PHP, the HEREDOC string declarations are really useful for outputting a block of html. You can have it parse in variables just by prefixing them with $, but for more complicated syntax (like $va...
2
Solved
I tried to implement the example provided by Docker itself (https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/)
# syntax=docker/dockerfile:1.3-labs
FROM ubuntu:20.04
RUN <<...
Hulett asked 18/1, 2023 at 13:43
8
Solved
Consider:
<?php
define('my_const', 100);
echo <<<MYECHO
<p>The value of my_const is {my_const}.</p>
MYECHO;
?>
If I put a variable inside the braces, it prints out....
7
Solved
I want to print code into a file using cat <<EOF >>:
cat <<EOF >> brightup.sh
!/bin/bash
curr=`cat /sys/class/backlight/intel_backlight/actual_brightness`
if [ $curr -lt 44...
4
Solved
i was wondering if you can have conditional statments inside a heredocs, this is my script but it deosnt parse out the $username properly?
php code:
function doSomething($username) {
if (isset($...
Pavior asked 25/10, 2010 at 5:58
20
Solved
Is there a way of specifying multiline strings in batch in a way similar to heredoc in unix shells. Something similar to:
cat <<EOF > out.txt
bla
bla
..
EOF
The idea is to create a cust...
Evangelize asked 18/6, 2009 at 21:1
5
Solved
Right now this outputs the value I need on stdout. How can I capture it into a variable so I can use it in the rest of the script?
Requirements:
The script needs to be all in one file.
I'd pref...
7
Solved
I've already found some solutions, but can't know what happened...
Example 1:
<?php
echo <<< EOD
test
EOD;
Example 2:
<?php
echo <<< 'EOD'
test
EOD;
Output 1,2:
PH...
4
Solved
In bash I can create a script with a here-doc like so as per this site:
http://tldp.org/LDP/abs/html/abs-guide.html#GENERATESCRIPT
(
cat <<'EOF'
#!/bin/bash
#? [ ] / \ = + < > : ; " ,...
4
Solved
Is there a heredoc notation for strings in C#, preferably one where I don't have to escape anything (including double quotes, which are a quirk in verbatim strings)?
8
Solved
Is this possible at all and how?
Update: I need this because I create a file both from dynamic and static data.
Use case: I have a test directory. Each C file produces a test executable. With
S...
11
Solved
How can I write a here document to a file in Bash script?
9
Solved
I need my script to send an email from terminal. Based on what I've seen here and many other places online, I formatted it like this:
/var/mail -s "$SUBJECT" "$EMAIL" << EOF
Here's a line of...
3
Solved
I am trying to create a composite cloudwatch alarm using terraform. But unfortunately my terraform code breaks with the following error:
Error: error creating CloudWatch Composite Alarm
(node-coun...
Arlberg asked 17/5, 2021 at 23:19
4
Solved
I am trying to run some piece of Python code in a Bash script, so i wanted to understand what is the difference between:
#!/bin/bash
#your bash code
python -c "
#your py code
"
vs
python - <...
6
Solved
In python I can construct a HTML string without worrying about escaping special characters like < or " by simply enclosing the string in triple quotes like:
html_string = """
<html>
<b...
Papeterie asked 20/4, 2010 at 20:43
43
Solved
I have the following code in Ruby. I want to convert this code into JavaScript. What is the equivalent code in JS?
text = <<"HERE"
This
Is
A
Multiline
String
HERE
Partin asked 30/4, 2009 at 2:11
5
Solved
I need to execute series of commands inside an interactive program/utility with parameterized values. Is there a way to loop inside heredoc ? Like below .. Not sure if eval can be of any help here....
2
Solved
I just upgraded to PHP 7.3 and I'm getting this error:
Invalid body indentation level (expecting an indentation level of at least 4)
Here is the code:
$html = <<<HTML
<html>
<...
8
Solved
For example:
$sql = <<<MySQL_QUERY
1
What is the <( ) syntax in shell / bash, and how do I search for it (meaning: what's it called)?
Is this related to the "heredoc" syntax?
Example: Pass a password to ssh in pure ...
Sidwell asked 9/11, 2021 at 0:2
2
Solved
Terraform keeps changing line endings of the multi-line heredoc depending on the runtime environment
I have this terraform resource (a bit simplified for clarity):
resource "azurerm_key_vault_secret" "env_secrets" {
name = "my-secret"
key_vault_id = var.key_vault_id...
Charlean asked 30/9, 2021 at 7:38
12
Solved
The definition of a here-document is here:
http://en.wikipedia.org/wiki/Here_document
How can you type a tab in a here-document? Such as this:
cat > prices.txt << EOF
coffee\t$1.50
tea\t...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.