How to escape the null character in here-document?(bash and/or dash)How to disable emacs here document...

Roman Numerals equation 1

How long is the D&D Starter Set campaign?

Digits in an algebraic irrational number

How much mayhem could I cause as a sentient fish?

Why Normality assumption in linear regression

Highly technological aliens land nuclear fusion powered ships in medieval city and slaughter everyone, using swords?

In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?

What's a good word to describe a public place that looks like it wouldn't be rough?

Early credit roll before the end of the film

Program that converts a number to a letter of the alphabet

Dilemma of explaining to interviewer that he is the reason for declining second interview

Why publish a research paper when a blog post or a lecture slide can have more citation count than a journal paper?

Intern applicant asking for compensation equivalent to that of permanent employee

Is a debit card dangerous in my situation?

How do Chazal know that the descendants of a Mamzer may never marry into the general populace?

Can an insurance company drop you after receiving a bill and refusing to pay?

Why would the Pakistan airspace closure cancel flights not headed to Pakistan itself?

Can I become debt free or should I file bankruptcy ? How to manage my debt and finances?

What happens to output if OPAMP its supply is tweaked?

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

Writing a character who is going through a civilizing process without overdoing it?

CREATE ASSEMBLY System.DirectoryServices.AccountManagement.dll without enabling TRUSTWORTHY

How to limit sight distance to 1 km

Eww, those bytes are gross



How to escape the null character in here-document?(bash and/or dash)


How to disable emacs here document completionHow to print “$” in here-documentCalling bash from sh (dash) with commands read from args, and “Unterminated quoted string”/“unexpected EOF”How to combine Bash's process substitution with HERE-document?Null and escape charactersIs it possible to use ANSI color escape codes in Bash here-documents?How to escape $ in here-documentHere documents as multiple lines command within the bashWhat are the differences between here document and here string in their purposes?Dash - how to escape strange path characters













1















For example, I want to perform shuf --zero-terminated on multi-line strings with here-document.










share|improve this question























  • I don't think you can do this in a here-document in either of those shells. Shells are generally not good with nulls (except zsh). Why do you want a here-document specifically?

    – Michael Homer
    3 hours ago











  • @MichaelHomer Because I can't pass the multi-line strings entity(i.e string include the newline character) to shuf as one single entity.

    – illiterate
    3 hours ago











  • @illiterate What is generating these multi-line NUL-separated strings? Is there some reason that you can't store them in a file instead of a here-string?

    – John1024
    3 hours ago
















1















For example, I want to perform shuf --zero-terminated on multi-line strings with here-document.










share|improve this question























  • I don't think you can do this in a here-document in either of those shells. Shells are generally not good with nulls (except zsh). Why do you want a here-document specifically?

    – Michael Homer
    3 hours ago











  • @MichaelHomer Because I can't pass the multi-line strings entity(i.e string include the newline character) to shuf as one single entity.

    – illiterate
    3 hours ago











  • @illiterate What is generating these multi-line NUL-separated strings? Is there some reason that you can't store them in a file instead of a here-string?

    – John1024
    3 hours ago














1












1








1








For example, I want to perform shuf --zero-terminated on multi-line strings with here-document.










share|improve this question














For example, I want to perform shuf --zero-terminated on multi-line strings with here-document.







bash dash






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 4 hours ago









illiterateilliterate

325111




325111













  • I don't think you can do this in a here-document in either of those shells. Shells are generally not good with nulls (except zsh). Why do you want a here-document specifically?

    – Michael Homer
    3 hours ago











  • @MichaelHomer Because I can't pass the multi-line strings entity(i.e string include the newline character) to shuf as one single entity.

    – illiterate
    3 hours ago











  • @illiterate What is generating these multi-line NUL-separated strings? Is there some reason that you can't store them in a file instead of a here-string?

    – John1024
    3 hours ago



















  • I don't think you can do this in a here-document in either of those shells. Shells are generally not good with nulls (except zsh). Why do you want a here-document specifically?

    – Michael Homer
    3 hours ago











  • @MichaelHomer Because I can't pass the multi-line strings entity(i.e string include the newline character) to shuf as one single entity.

    – illiterate
    3 hours ago











  • @illiterate What is generating these multi-line NUL-separated strings? Is there some reason that you can't store them in a file instead of a here-string?

    – John1024
    3 hours ago

















I don't think you can do this in a here-document in either of those shells. Shells are generally not good with nulls (except zsh). Why do you want a here-document specifically?

– Michael Homer
3 hours ago





I don't think you can do this in a here-document in either of those shells. Shells are generally not good with nulls (except zsh). Why do you want a here-document specifically?

– Michael Homer
3 hours ago













@MichaelHomer Because I can't pass the multi-line strings entity(i.e string include the newline character) to shuf as one single entity.

– illiterate
3 hours ago





@MichaelHomer Because I can't pass the multi-line strings entity(i.e string include the newline character) to shuf as one single entity.

– illiterate
3 hours ago













@illiterate What is generating these multi-line NUL-separated strings? Is there some reason that you can't store them in a file instead of a here-string?

– John1024
3 hours ago





@illiterate What is generating these multi-line NUL-separated strings? Is there some reason that you can't store them in a file instead of a here-string?

– John1024
3 hours ago










3 Answers
3






active

oldest

votes


















3














Here-documents in Bash and dash don't support this. You can't store a null in a variable, they are removed from command substitutions, you can't write one in literally, and you can't use ANSI-C quoting inside the here-document. Neither shell is null-friendly and they are generally treated as (C-style) string terminators if one does get in.



You have a few options: use a real file, use zsh, use process substitution, or use standard input.





You can do exactly what you want in zsh, which is much more null-friendly.



zsh% null=$(printf 'x00')
zsh% hexdump -C <<EOT
heredoc> a${null}b${null}
heredoc> EOT
00000000 61 00 62 00 0a |a.b..|
00000005


Note though that heredocs have an implicit terminating newline, which may not be desirable (it'll be an extra field for shuf after the final null).





For Bash, you can use process substitution almost equivalently to your heredoc in combination with printf or echo -e to create nulls inline:



bash$ hexdump -C < <(
printf 'item 1x00itemn2x00'
)
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


This is not necessarily entirely equivalent to a here-document, because those are often secretly put into real files by the shell (which matters for seekability, among other things).



Since you probably want to suppress terminating newlines, you can't even use a heredoc internally within the commands there - it has to be printf/echo -ne if safe to get fine-grained control over the output.





You can't do process substitution in dash, but in any shell you could pipe in standard input from a subshell:



dash$ (
printf 'item 1x00'
printf 'itemn2x00'
) | hexdump -C
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


shuf is happy to read from standard input by default, so that should work for your concrete use case as I understand it. If you have a more complex command, being on the right-hand side of a pipeline can introduce some confounding elements with scoping.





Finally, you could write your data into a real file using printf and use that instead of a here-document. That option has been covered in the other answer. You'll need to make sure you clean up the file afterwards, and may want to use mktemp or similar if available to create a safe filename if there are any live security concerns.






share|improve this answer
























  • Thank you, this is one elaborate answer, but leak the simple script work in bash and dash

    – illiterate
    13 mins ago



















2














I do not think you can do what you want in a heredoc. However it is trivial to do using echo as the following example shows:



$ cat demo
#!/bin/bash

echo -ne "one" > outfile
echo -ne "two" >> outfile
echo -ne "three" >> outfile

$ ./demo
$ od -a outfile
0000000 o n e nul t w o nul t h r e e nul
0000016
$





share|improve this answer
























  • Thank you, but echo is not trivial, see my answer

    – illiterate
    24 mins ago



















1














Thank you all.
Let I post one answer base on you all and maybe best for me.



This script works nice in bash and dash, no require real file or process substitution in bash, also external echo(1)'s usage simpler than printf(1)(i.e with echo you less worry format string escape problem)



#!/bin/sh
#ensure use external "echo" to bypass shell special echo behavior also see:https://stackoverflow.com/a/29541368/9377221
#env echo -ne "1x002" | shuf --zero-terminated
#but you don't need env, let's make script fast
/bin/echo -ne "[tag1]
key1=value1
key2=value2
[/tag1]
x00[tag2]
key3=value3
key4=value4
[/tag2]
x00" | shuf --zero-terminated
#also see man echo





share|improve this answer



















  • 1





    Don't use echo for that, not even /bin/echo (on GNU systems for instance, whether /bin/echo supports -e depends on whether $POSIXLY_CORRECT is in the environment or not, on many other systems, /bin/echo doesn't support -e or -n or x00). Use printf '%s' 'first record' 'second record'... | shuf...

    – Stéphane Chazelas
    5 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503682%2fhow-to-escape-the-null-character-in-here-documentbash-and-or-dash%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Here-documents in Bash and dash don't support this. You can't store a null in a variable, they are removed from command substitutions, you can't write one in literally, and you can't use ANSI-C quoting inside the here-document. Neither shell is null-friendly and they are generally treated as (C-style) string terminators if one does get in.



You have a few options: use a real file, use zsh, use process substitution, or use standard input.





You can do exactly what you want in zsh, which is much more null-friendly.



zsh% null=$(printf 'x00')
zsh% hexdump -C <<EOT
heredoc> a${null}b${null}
heredoc> EOT
00000000 61 00 62 00 0a |a.b..|
00000005


Note though that heredocs have an implicit terminating newline, which may not be desirable (it'll be an extra field for shuf after the final null).





For Bash, you can use process substitution almost equivalently to your heredoc in combination with printf or echo -e to create nulls inline:



bash$ hexdump -C < <(
printf 'item 1x00itemn2x00'
)
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


This is not necessarily entirely equivalent to a here-document, because those are often secretly put into real files by the shell (which matters for seekability, among other things).



Since you probably want to suppress terminating newlines, you can't even use a heredoc internally within the commands there - it has to be printf/echo -ne if safe to get fine-grained control over the output.





You can't do process substitution in dash, but in any shell you could pipe in standard input from a subshell:



dash$ (
printf 'item 1x00'
printf 'itemn2x00'
) | hexdump -C
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


shuf is happy to read from standard input by default, so that should work for your concrete use case as I understand it. If you have a more complex command, being on the right-hand side of a pipeline can introduce some confounding elements with scoping.





Finally, you could write your data into a real file using printf and use that instead of a here-document. That option has been covered in the other answer. You'll need to make sure you clean up the file afterwards, and may want to use mktemp or similar if available to create a safe filename if there are any live security concerns.






share|improve this answer
























  • Thank you, this is one elaborate answer, but leak the simple script work in bash and dash

    – illiterate
    13 mins ago
















3














Here-documents in Bash and dash don't support this. You can't store a null in a variable, they are removed from command substitutions, you can't write one in literally, and you can't use ANSI-C quoting inside the here-document. Neither shell is null-friendly and they are generally treated as (C-style) string terminators if one does get in.



You have a few options: use a real file, use zsh, use process substitution, or use standard input.





You can do exactly what you want in zsh, which is much more null-friendly.



zsh% null=$(printf 'x00')
zsh% hexdump -C <<EOT
heredoc> a${null}b${null}
heredoc> EOT
00000000 61 00 62 00 0a |a.b..|
00000005


Note though that heredocs have an implicit terminating newline, which may not be desirable (it'll be an extra field for shuf after the final null).





For Bash, you can use process substitution almost equivalently to your heredoc in combination with printf or echo -e to create nulls inline:



bash$ hexdump -C < <(
printf 'item 1x00itemn2x00'
)
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


This is not necessarily entirely equivalent to a here-document, because those are often secretly put into real files by the shell (which matters for seekability, among other things).



Since you probably want to suppress terminating newlines, you can't even use a heredoc internally within the commands there - it has to be printf/echo -ne if safe to get fine-grained control over the output.





You can't do process substitution in dash, but in any shell you could pipe in standard input from a subshell:



dash$ (
printf 'item 1x00'
printf 'itemn2x00'
) | hexdump -C
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


shuf is happy to read from standard input by default, so that should work for your concrete use case as I understand it. If you have a more complex command, being on the right-hand side of a pipeline can introduce some confounding elements with scoping.





Finally, you could write your data into a real file using printf and use that instead of a here-document. That option has been covered in the other answer. You'll need to make sure you clean up the file afterwards, and may want to use mktemp or similar if available to create a safe filename if there are any live security concerns.






share|improve this answer
























  • Thank you, this is one elaborate answer, but leak the simple script work in bash and dash

    – illiterate
    13 mins ago














3












3








3







Here-documents in Bash and dash don't support this. You can't store a null in a variable, they are removed from command substitutions, you can't write one in literally, and you can't use ANSI-C quoting inside the here-document. Neither shell is null-friendly and they are generally treated as (C-style) string terminators if one does get in.



You have a few options: use a real file, use zsh, use process substitution, or use standard input.





You can do exactly what you want in zsh, which is much more null-friendly.



zsh% null=$(printf 'x00')
zsh% hexdump -C <<EOT
heredoc> a${null}b${null}
heredoc> EOT
00000000 61 00 62 00 0a |a.b..|
00000005


Note though that heredocs have an implicit terminating newline, which may not be desirable (it'll be an extra field for shuf after the final null).





For Bash, you can use process substitution almost equivalently to your heredoc in combination with printf or echo -e to create nulls inline:



bash$ hexdump -C < <(
printf 'item 1x00itemn2x00'
)
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


This is not necessarily entirely equivalent to a here-document, because those are often secretly put into real files by the shell (which matters for seekability, among other things).



Since you probably want to suppress terminating newlines, you can't even use a heredoc internally within the commands there - it has to be printf/echo -ne if safe to get fine-grained control over the output.





You can't do process substitution in dash, but in any shell you could pipe in standard input from a subshell:



dash$ (
printf 'item 1x00'
printf 'itemn2x00'
) | hexdump -C
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


shuf is happy to read from standard input by default, so that should work for your concrete use case as I understand it. If you have a more complex command, being on the right-hand side of a pipeline can introduce some confounding elements with scoping.





Finally, you could write your data into a real file using printf and use that instead of a here-document. That option has been covered in the other answer. You'll need to make sure you clean up the file afterwards, and may want to use mktemp or similar if available to create a safe filename if there are any live security concerns.






share|improve this answer













Here-documents in Bash and dash don't support this. You can't store a null in a variable, they are removed from command substitutions, you can't write one in literally, and you can't use ANSI-C quoting inside the here-document. Neither shell is null-friendly and they are generally treated as (C-style) string terminators if one does get in.



You have a few options: use a real file, use zsh, use process substitution, or use standard input.





You can do exactly what you want in zsh, which is much more null-friendly.



zsh% null=$(printf 'x00')
zsh% hexdump -C <<EOT
heredoc> a${null}b${null}
heredoc> EOT
00000000 61 00 62 00 0a |a.b..|
00000005


Note though that heredocs have an implicit terminating newline, which may not be desirable (it'll be an extra field for shuf after the final null).





For Bash, you can use process substitution almost equivalently to your heredoc in combination with printf or echo -e to create nulls inline:



bash$ hexdump -C < <(
printf 'item 1x00itemn2x00'
)
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


This is not necessarily entirely equivalent to a here-document, because those are often secretly put into real files by the shell (which matters for seekability, among other things).



Since you probably want to suppress terminating newlines, you can't even use a heredoc internally within the commands there - it has to be printf/echo -ne if safe to get fine-grained control over the output.





You can't do process substitution in dash, but in any shell you could pipe in standard input from a subshell:



dash$ (
printf 'item 1x00'
printf 'itemn2x00'
) | hexdump -C
00000000 69 74 65 6d 20 31 00 69 74 65 6d 0a 32 00 |item 1.item.2.|
0000000e


shuf is happy to read from standard input by default, so that should work for your concrete use case as I understand it. If you have a more complex command, being on the right-hand side of a pipeline can introduce some confounding elements with scoping.





Finally, you could write your data into a real file using printf and use that instead of a here-document. That option has been covered in the other answer. You'll need to make sure you clean up the file afterwards, and may want to use mktemp or similar if available to create a safe filename if there are any live security concerns.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 hours ago









Michael HomerMichael Homer

49.3k8133172




49.3k8133172













  • Thank you, this is one elaborate answer, but leak the simple script work in bash and dash

    – illiterate
    13 mins ago



















  • Thank you, this is one elaborate answer, but leak the simple script work in bash and dash

    – illiterate
    13 mins ago

















Thank you, this is one elaborate answer, but leak the simple script work in bash and dash

– illiterate
13 mins ago





Thank you, this is one elaborate answer, but leak the simple script work in bash and dash

– illiterate
13 mins ago













2














I do not think you can do what you want in a heredoc. However it is trivial to do using echo as the following example shows:



$ cat demo
#!/bin/bash

echo -ne "one" > outfile
echo -ne "two" >> outfile
echo -ne "three" >> outfile

$ ./demo
$ od -a outfile
0000000 o n e nul t w o nul t h r e e nul
0000016
$





share|improve this answer
























  • Thank you, but echo is not trivial, see my answer

    – illiterate
    24 mins ago
















2














I do not think you can do what you want in a heredoc. However it is trivial to do using echo as the following example shows:



$ cat demo
#!/bin/bash

echo -ne "one" > outfile
echo -ne "two" >> outfile
echo -ne "three" >> outfile

$ ./demo
$ od -a outfile
0000000 o n e nul t w o nul t h r e e nul
0000016
$





share|improve this answer
























  • Thank you, but echo is not trivial, see my answer

    – illiterate
    24 mins ago














2












2








2







I do not think you can do what you want in a heredoc. However it is trivial to do using echo as the following example shows:



$ cat demo
#!/bin/bash

echo -ne "one" > outfile
echo -ne "two" >> outfile
echo -ne "three" >> outfile

$ ./demo
$ od -a outfile
0000000 o n e nul t w o nul t h r e e nul
0000016
$





share|improve this answer













I do not think you can do what you want in a heredoc. However it is trivial to do using echo as the following example shows:



$ cat demo
#!/bin/bash

echo -ne "one" > outfile
echo -ne "two" >> outfile
echo -ne "three" >> outfile

$ ./demo
$ od -a outfile
0000000 o n e nul t w o nul t h r e e nul
0000016
$






share|improve this answer












share|improve this answer



share|improve this answer










answered 3 hours ago









fpmurphyfpmurphy

2,420915




2,420915













  • Thank you, but echo is not trivial, see my answer

    – illiterate
    24 mins ago



















  • Thank you, but echo is not trivial, see my answer

    – illiterate
    24 mins ago

















Thank you, but echo is not trivial, see my answer

– illiterate
24 mins ago





Thank you, but echo is not trivial, see my answer

– illiterate
24 mins ago











1














Thank you all.
Let I post one answer base on you all and maybe best for me.



This script works nice in bash and dash, no require real file or process substitution in bash, also external echo(1)'s usage simpler than printf(1)(i.e with echo you less worry format string escape problem)



#!/bin/sh
#ensure use external "echo" to bypass shell special echo behavior also see:https://stackoverflow.com/a/29541368/9377221
#env echo -ne "1x002" | shuf --zero-terminated
#but you don't need env, let's make script fast
/bin/echo -ne "[tag1]
key1=value1
key2=value2
[/tag1]
x00[tag2]
key3=value3
key4=value4
[/tag2]
x00" | shuf --zero-terminated
#also see man echo





share|improve this answer



















  • 1





    Don't use echo for that, not even /bin/echo (on GNU systems for instance, whether /bin/echo supports -e depends on whether $POSIXLY_CORRECT is in the environment or not, on many other systems, /bin/echo doesn't support -e or -n or x00). Use printf '%s' 'first record' 'second record'... | shuf...

    – Stéphane Chazelas
    5 mins ago
















1














Thank you all.
Let I post one answer base on you all and maybe best for me.



This script works nice in bash and dash, no require real file or process substitution in bash, also external echo(1)'s usage simpler than printf(1)(i.e with echo you less worry format string escape problem)



#!/bin/sh
#ensure use external "echo" to bypass shell special echo behavior also see:https://stackoverflow.com/a/29541368/9377221
#env echo -ne "1x002" | shuf --zero-terminated
#but you don't need env, let's make script fast
/bin/echo -ne "[tag1]
key1=value1
key2=value2
[/tag1]
x00[tag2]
key3=value3
key4=value4
[/tag2]
x00" | shuf --zero-terminated
#also see man echo





share|improve this answer



















  • 1





    Don't use echo for that, not even /bin/echo (on GNU systems for instance, whether /bin/echo supports -e depends on whether $POSIXLY_CORRECT is in the environment or not, on many other systems, /bin/echo doesn't support -e or -n or x00). Use printf '%s' 'first record' 'second record'... | shuf...

    – Stéphane Chazelas
    5 mins ago














1












1








1







Thank you all.
Let I post one answer base on you all and maybe best for me.



This script works nice in bash and dash, no require real file or process substitution in bash, also external echo(1)'s usage simpler than printf(1)(i.e with echo you less worry format string escape problem)



#!/bin/sh
#ensure use external "echo" to bypass shell special echo behavior also see:https://stackoverflow.com/a/29541368/9377221
#env echo -ne "1x002" | shuf --zero-terminated
#but you don't need env, let's make script fast
/bin/echo -ne "[tag1]
key1=value1
key2=value2
[/tag1]
x00[tag2]
key3=value3
key4=value4
[/tag2]
x00" | shuf --zero-terminated
#also see man echo





share|improve this answer













Thank you all.
Let I post one answer base on you all and maybe best for me.



This script works nice in bash and dash, no require real file or process substitution in bash, also external echo(1)'s usage simpler than printf(1)(i.e with echo you less worry format string escape problem)



#!/bin/sh
#ensure use external "echo" to bypass shell special echo behavior also see:https://stackoverflow.com/a/29541368/9377221
#env echo -ne "1x002" | shuf --zero-terminated
#but you don't need env, let's make script fast
/bin/echo -ne "[tag1]
key1=value1
key2=value2
[/tag1]
x00[tag2]
key3=value3
key4=value4
[/tag2]
x00" | shuf --zero-terminated
#also see man echo






share|improve this answer












share|improve this answer



share|improve this answer










answered 26 mins ago









illiterateilliterate

325111




325111








  • 1





    Don't use echo for that, not even /bin/echo (on GNU systems for instance, whether /bin/echo supports -e depends on whether $POSIXLY_CORRECT is in the environment or not, on many other systems, /bin/echo doesn't support -e or -n or x00). Use printf '%s' 'first record' 'second record'... | shuf...

    – Stéphane Chazelas
    5 mins ago














  • 1





    Don't use echo for that, not even /bin/echo (on GNU systems for instance, whether /bin/echo supports -e depends on whether $POSIXLY_CORRECT is in the environment or not, on many other systems, /bin/echo doesn't support -e or -n or x00). Use printf '%s' 'first record' 'second record'... | shuf...

    – Stéphane Chazelas
    5 mins ago








1




1





Don't use echo for that, not even /bin/echo (on GNU systems for instance, whether /bin/echo supports -e depends on whether $POSIXLY_CORRECT is in the environment or not, on many other systems, /bin/echo doesn't support -e or -n or x00). Use printf '%s' 'first record' 'second record'... | shuf...

– Stéphane Chazelas
5 mins ago





Don't use echo for that, not even /bin/echo (on GNU systems for instance, whether /bin/echo supports -e depends on whether $POSIXLY_CORRECT is in the environment or not, on many other systems, /bin/echo doesn't support -e or -n or x00). Use printf '%s' 'first record' 'second record'... | shuf...

– Stéphane Chazelas
5 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503682%2fhow-to-escape-the-null-character-in-here-documentbash-and-or-dash%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Benedict Cumberbatch Contingut Inicis Debut professional Premis Filmografia bàsica Premis i...

Monticle de plataforma Contingut Est de Nord Amèrica Interpretacions Altres cultures Vegeu...

Escacs Janus Enllaços externs Menú de navegacióEscacs JanusJanusschachBrainKing.comChessV