Multiline string literals that use similar syntax, preserving line breaks and other whitespace (including indentation) in the text.
Questions tagged [herestring]
50 questions
0
votes
1 answer
Symfony console, file paths, /dev/fd/0 trick
I have my own symfony console commands, some of which take a filename as the argument.
eg.
$ php app/console mycommands:doTheThing /path/to/my/file.txt
I have tried using the /dev/fd/0 trick to use a string instead of a file here, however it's still…

Brian Brownton
- 1,313
- 14
- 31
0
votes
1 answer
Binary safe bash 'here string'?
I'd like to save output of a command to a variable for later multiple uses. Bash provides Here String functionality for that purpose. However it is not binary safe. It sometimes adds new lines:
$ a=''
$ xxd <<< "$a"
00000000: 0a
Is there any…

czerny
- 15,090
- 14
- 68
- 96
0
votes
3 answers
Using builtin read with pipeline and here strings
I'm processing a package of pictures, from which "file" returns the following:
$ file pic.jpg
pic.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 96x96, segment length 16, baseline, precision 8, 231x288, frames 3
$ file pic.jpg |…

TallFurryMan
- 70
- 8
-1
votes
1 answer
How to expand env var in ANSI C-like string and use literal newline?
I am using herestring to pass a string (two input values with newlines) as standard input to an installer executable.
For example, executing an installer with two inputs /var/tmp and yes
#!/bin/bash
# run_installer.sh
./installer <<<…

James Wierzba
- 16,176
- 14
- 79
- 120
-2
votes
1 answer
What is the advantage of using bash -c over using a here string
Is there any real benefit to using bash -c 'some command' over using bash <<< 'some command'
They seem to achieve the same effect.

yosefrow
- 2,128
- 20
- 29