Skip to main content

Questions tagged [here-document]

0 votes
0 answers
49 views

For a school project, I am tasked with making my own (simplified) shell, with bash being the reference point. This includes replicating heredoc behavior which was fun until I stumbled upon variable ...
Mika's user avatar
  • 101
2 votes
1 answer
274 views

First, I do know this is a security risk. I do know about ssh keys and sshpass. This belongs to a fun project. I wondered if a bash Here-Document could be used as a password input for ssh. I ...
Simon Huenecke's user avatar
7 votes
2 answers
892 views

Consider the following script: #!/bin/bash foo=Hello bar=Word cat <<EOF No quotes single word delimiter expands $foo $bar EOF cat <<'EOF' Single-quoted single word delimiter does not ...
merlin2011's user avatar
  • 4,209
8 votes
1 answer
933 views

I found the following in man bash as a definition of interactive shell: An interactive shell is one started without non-option arguments (unless -s is specified) and without the -c option whose ...
Yakog's user avatar
  • 517
0 votes
1 answer
97 views

Show lines passed by here-document in the stdout: cat <<EOF foo bar baz EOF foo bar baz I want to match some string with grep via pipe: cat <<EOF foo bar baz EOF |grep 'ba' Why can't ...
showkey's user avatar
  • 611
6 votes
3 answers
1k views

This code works fine on Linux but not Mac OS: #!/usr/bin/env bash foo=$(cat <<EOF "\[^"\]+" EOF ) printf "%s" "$foo" It fails on Mac with ./test.sh: line 6: ...
Jason Gross's user avatar
0 votes
2 answers
180 views

I do some automatic checks and want to send a mail if a file has changed. I want the mail body to contain the new version of the file, some static text and the old version of the file, so what I do is ...
MortenSickel's user avatar
  • 1,453
11 votes
1 answer
1k views

This very simplified version of my script #!/usr/bin/env bash example="$(bash -rs <<'BASH' -- 'This has been executed in restricted shell' echo "$1" BASH )" echo "$...
pedral's user avatar
  • 121
5 votes
3 answers
2k views

I have this command to run a checksum in some software I want to install: echo "85762db0edc00ce19a2cd5496d1627903e6198ad850bbbdefb2ceaa46bd20cbd install.sh" | sha256sum -c But I would like ...
Cnnewb's user avatar
  • 51
5 votes
1 answer
341 views

Assuming I have a variable v="c d e f g" and a file with the content: line1 $v line3 How can I make a bash script print this file with the content of the variable in line 2 as if I was ...
nath's user avatar
  • 6,114
0 votes
1 answer
142 views

How is one supposed to write this? print <<EOF; if $x bla EOF I think it is called postfix notation, and a here-doc. I get a syntax error. OK, I guess I'll just use print "bla" if $x; ...
Dan Jacobson's user avatar
0 votes
2 answers
92 views

I usually run server scripts like this, with a here-document. But when I test if a directory exists, the script continues even though the test fails -- why? ssh $user@$ip /bin/bash <<SCRIPT if [...
Vinn's user avatar
  • 236
0 votes
0 answers
913 views

I have a bash script that connects to a remote machine via SSH and runs a series of commands. It seems that the heredoc within the outer script is not aligning properly, and I keep getting an error. -...
George Udosen's user avatar
0 votes
2 answers
171 views

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/...
Erwann's user avatar
  • 729
0 votes
1 answer
1k views

When I run buildah, I typically use a heredoc, ctr=$(buildah from alpine:3); buildah run $ctr sh -- <<EOF apk update; apk add git; EOF buildah commit $ctr heredoc_demo; However, when I ...
Evan Carroll's user avatar
  • 35.2k

15 30 50 per page
1
2 3 4 5
17