Cat Eof Bash Variables Assignment

There are many ways to save a multi line string in bash.
This is post just shows how to output a multiline string.

The Basics – Quoting Variables

From the bash(1) man page:

Also single quotes(e.g. ‘EOF’) or double quotes(e.g. “EOF”) can be used as stop tokens
The minus trims leading spaces or blanks. The quotes around the token prevent variable expansion inside document.

Examples

i. heredoc with variable expansion

ii. heredoc without variable expansion

The quoted “EOF” directive is determines whether or not variable name inside the multi line string will be expanded.

iii. heredoc without variable expansion – example 2

Escaping dollar inside a heredoc string is error prone and should be avoided!
So option ii. is the best

1. Set Multi Line Text to a String Variable

2. Set Multi Line Text to a String Variable

3. Set Multi Line Text to a String Variable

4. Set Multi Line Text to a String Variable

5. Set Multi Line Text to a String Variable

6. Save A Multi Line String to a Text File

Test File Contents

7. Save A Multi Line String to a Text File

this redirect does not work …

8. Save A Multi Line String to a Text File

9. Append a Multi Line String to a Text File

10. Save Multi Line String to a Text File

11. Save Multi Line String to a Text File

tee –help

References

1. Heredoc Quoting – Credit to Ignacio Vazquez-Abrams: http://serverfault.com/questions/399428/how-do-you-escape-characters-in-heredoc
2. eredoc Quoting – Credit to Dennis Williamson: http://stackoverflow.com/questions/3731513/how-do-you-type-a-tab-in-a-bash-here-document
3. http://serverfault.com/questions/72476/clean-way-to-write-complex-multi-line-string-to-a-variable
4. http://arstechnica.com/civis/viewtopic.php?p=21091503
5. http://superuser.com/questions/201829/sudo-permission-denied
6. http://stackoverflow.com/questions/4937792/using-variables-inside-a-bash-heredoc
7. http://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work
8. http://www.unix.com/shell-programming-scripting/187477-variables-heredoc.html

Ifany characters inwordare quoted,
the delimiter isthe result of quote removal on word,
andthe lines inthe here-document are notexpanded.
cat>myfile.txt<<EOF
thisfilehas$variable$names$inside
#print out the content of myfile.txt
#this file has    
inside="expanded variables"
cat>myfile.txt<<EOF
thisfilehas$variable$names$inside
#print out the content of myfile.txt
#this file has ONE TWO expanded variables
cat>myfile.txt<<"EOF"
thisfilehas$variable$dollar$name$inside
#print out the content of myfile.txt
#this file has $variable $dollar $name $inside
cat>myfile.txt<<EOF
thisfilehas$variable\$dollar\$name\$inside
#print out the content of myfile.txt
#this file has $variable $dollar $name $inside
read-d''stringvar<<-"_EOF_"
all the leading dollars inthe$variable$nameare$retained
# all the leading dollars in the $variable $name are $retained
read-d''help<<-"_EOF_"
  usage:up[--level<n>|-n<levels>][--help][--version]
  Report bugs to:
  up home page:
VARIABLE1="<?xml version=\"1.0\"encoding='UTF-8'?>
  <img src="a-vs-b.jpg"/>
  <caption>Thus isafuture post on Multi Line Stringsinbash
  <date>1511</date>-<date>1512</date>.</caption>
VARIABLE2=$(cat<<EOF
<?xml version="1.0"encoding='UTF-8'?>
  <img src="a-vs-b.jpg"/>
  <caption>Thus isafuture post on Multi Line Stringsinbash
  <date>1511</date>-<date>1512</date>.</caption>
VARABLE3=`cat<<EOF
<?xml version="1.0"encoding='UTF-8'?>
  <img src="a-vs-b.jpg"/>
  <caption>Thus isafuture post on Multi Line Stringsinbash
  <date>1511</date>-<date>1512</date>.</caption>
cat>heredocfile.txt<<_EOF_
# and then, change your echo statement to include the '-e' option
# which will turn on escape sequence processing:
echo-e$USAGE>&2
sudo cat>/aaaa.txt<<_EOF_
# sudo and >>: permission denied
sudo tee/aaa.txt<<EOF
  echo"Hello World 20314"
sudo tee-a  /aaa.txt<<EOF
echo"This Line is appended"
sudo sh-c"cat > /aaa.txt"<<"EOT"
thistext gets saved assudo-$10-ten dollars...
#this text gets saved as sudo - $10 - ten dollars ...
cat<<"EOF"|sudo tee/aaa.txt
Usage:tee[OPTION]...[FILE]...
Copy standard input toeachFILE,andalso tostandard output.
  -a,--append              append tothe given FILEs,donotoverwrite
  -i,--ignore-interrupts   ignore interrupt signals
      --help     display thishelp andexit
      --version  output version information andexit
IfaFILEis-,copy again tostandard output.
Report teebugs tobug-coreutils@gnu.org
GNU coreutils home page:<http://www.gnu.org/software/coreutils/>
General help using GNU software:<http://www.gnu.org/gethelp/>
Forcomplete documentation,run:info coreutils'tee invocation'
Posted in OS, ubuntu, unix.

In computing, a here document (here-document, here-text, heredoc, hereis, here-string or here-script) is a file literal or input stream literal: it is a section of a source code file that is treated as if it were a separate file. The term is also used for a form of multiline string literals that use similar syntax, preserving line breaks and other whitespace (including indentation) in the text.

Here documents originate in the Unix shell, and are found in sh, csh,[1]ksh, bash and zsh, among others. Here document-style string literals are found in various high-level languages, notably the Perl programming language (syntax inspired by Unix shell) and languages influenced by Perl, such as PHP and Ruby. Other high-level languages such as Python and Tcl have other facilities for multiline strings.

Here documents can be treated either as files or strings. Some shells treat them as a format string literal, allowing variable substitution and command substitution inside the literal.

The most common syntax for here documents, originating in Unix shells, is followed by a delimitingidentifier (often EOF or END[2]), followed, starting on the next line, by the text to be quoted, and then closed by the same delimiting identifier on its own line. This syntax is because here documents are formally stream literals, and the content of the document is redirected to stdin (standard input) of the preceding command; the here document syntax is by analogy with the syntax for input redirection, which is "take input from the following file".

Other languages often use substantially similar syntax, but details of syntax and actual functionality can vary significantly. When used simply for string literals, the does not indicate indirection, but is simply a starting delimiter convention. In some languages, such as Ruby, is also used for input redirection, thus resulting in being used twice if one wishes to redirect from a here document string literal.

File literals[edit]

Narrowly speaking, here documents are file literals or stream literals. These originate in the Unix shell, though similar facilities are available in some other languages.

Unix shells[edit]

Here documents are available in many Unix shells.
Take care with `quoted` content no escaped with \ because can cause errors.
In the following example, text is passed to the command (transliterating lower to upper-case) using a here document. This could be in a shell file, or entered interactively at a prompt.

$ tr a-z A-Z << END_TEXT> one two three> four five six> END_TEXTONE TWO THREEFOUR FIVE SIX

was used as the delimiting identifier. It specified the start and end of the here document. The redirect and the delimiting identifier do not need to be separated by a space: or both work equally well.

Appending a minus sign to the << has the effect that leading tabs are ignored. This allows indenting here documents in shell scripts (primarily for alignment with existing indentation) without changing their value:[a]

$ tr a-z A-Z <<- END_TEXT> one two three> four five six> END_TEXTONE TWO THREEFOUR FIVE SIX

This yields the same output, notably not indented.

By default, behavior is largely identical to the contents of double quotes: variables are interpolated, commands in backticks are evaluated, etc.[b]

$ cat << EOF> \$ Working dir "$PWD" `pwd`> EOF$ Working dir "/home/user" /home/user

This can be disabled by quoting any part of the label, which is then ended by the unquoted value;[c] the behavior is essentially identical to that if the contents were enclosed in single quotes. Thus for example by setting it in single quotes:

$ cat << 'EOF'> \$ Working dir "$PWD" `pwd`> EOF\$ Working dir "$PWD" `pwd`

Double quotes may also be used, but this is subject to confusion, because expansion does occur in a double-quoted string, but does not occur in a here document with double-quoted delimiter.[3] Single- and double-quoted delimiters are distinguished in some other languages, notably Perl (see below), where behavior parallels the corresponding string quoting.

Here strings[edit]

A here string (available in Bash, ksh, or zsh) is syntactically similar, consisting of , and effects input redirection from a word (a sequence treated as a unit by the shell, in this context generally a string literal). In this case the usual shell syntax is used for the word ("here string syntax"), with the only syntax being the redirection: a here string is an ordinary string used for input redirection, not a special kind of string.

A single word need not be quoted:

$ tr a-z A-Z <<< one ONE

In case of a string with spaces, it must be quoted:

$ tr a-z A-Z <<<'one two three'ONE TWO THREE

This could also be written as:

$FOO='one two three'$ tr a-z A-Z <<<$FOOONE TWO THREE

Multiline strings are acceptable, yielding:

$ tr a-z A-Z <<<'one> two three'ONETWO THREE

Note that leading and trailing newlines, if present, are included:

$ tr a-z A-Z <<<'> one> two three> 'ONETWO THREE$

The key difference from here documents is that, in here documents, the delimiters are on separate lines; the leading and trailing newlines are stripped. Here, the terminating delimiter can be specified.

Here strings are particularly useful for commands that often take short input, such as the calculator bc:

$ bc <<<2^10 1024

Note that here string behavior can also be accomplished (reversing the order) via piping and the command, as in:

$echo'one two three'| tr a-z A-Z ONE TWO THREE

however here strings are particularly useful when the last command needs to run in the current process, as is the case with the builtin:

$ echo'one two three'|read a b c $ echo$a$b$c

yields nothing, while

$read a b c <<<'one two three'$echo$a$b$cone two three

This happens because in the previous example piping causes to run in a subprocess, and as such can not affect the environment of the parent process.

Microsoft NMAKE[edit]

In Microsoft NMAKE, here documents are referred to as inline files. Inline files are referenced as or : the first notation creates a temporary file, the second notation creates (or overwrites) the file with the specified pathname. An inline file is terminated with on a line by itself, optionally followed by the (case-insensitive) keyword or to indicate whether the created file should be kept.

target0: dependent0 command0 << temporary inline file ... << target1: dependent1 command1 << temporary, but preserved inline file ... <<KEEP target2: dependent2 command2 <<filename2 named, but discarded inline file ... <<NOKEEP target3: dependent3 command3 <<filename3 named inline file ... <<KEEP

R[edit]

R does not have file literals, but provides equivalent functionality by combining string literals with a string-to-file function. R allows arbitrary whitespace, including newlines, in strings. A string then can be turned into a file descriptor using the function. For example, the following turns a data table embedded in the source code into a data-frame variable:

str <-"State Population Income Illiteracy Life.Exp Murder HS.Grad FrostAlabama 3615 3624 2.1 69.05 15.1 41.3 20Alaska 365 6315 1.5 69.31 11.3 66.7 152Arizona 2212 4530 1.8 70.55 7.8 58.1 15Arkansas 2110 3378 1.9 70.66 10.1 39.9 65" x <- read.table(textConnection(str), header=TRUE, row.names=1)

Data segment[edit]

Perl[4] and Ruby[5] have a form of file literal, which can be considered a form of data segment. In these languages, including the line (Perl) or (Ruby, old Perl) marks the end of the code segment and the start of the data segment. Only the contents prior to this line are executed, and the contents of the source file after this line are available as a file object: in Perl (e.g., ) and in Ruby. As an inline file, these are semantically similar to here documents, though there can be only one per script. However, in these languages the term "here document" instead refers to multiline string literals, as discussed below.

Data URI Scheme[edit]

As further explained in Data URI scheme, all major web browsers understand URIs that start with data: as here document.

Multiline string literals[edit]

The term "here document" or "here string" is also used for multiline string literals in various programming languages, notably Perl (syntax influenced by Unix shell), and languages influenced by Perl, notably PHP and Ruby. The shell-style syntax is often retained, despite not being used for input redirection.

Perl-influenced[edit]

Perl[edit]

In Perl there are several different ways to invoke here docs.[6] The delimiters around the tag have the same effect within the here doc as they would in a regular string literal: For example, using double quotes around the tag allows variables to be interpolated, but using single quotes doesn't, and using the tag without either behaves like double quotes. Using backticks as the delimiters around the tag runs the contents of the heredoc as a shell script. It is necessary to make sure that the end tag is at the beginning of the line or the tag will not be recognized by the interpreter.

Note that the here doc does not start at the tag—but rather starts on the next line. So the statement containing the tag continues on after the tag.

Here is an example with double quotes:

my$sender="Buffy the Vampire Slayer";my$recipient="Spike";print<<"END";Dear $recipient,I wish you to leave Sunnydale and never return.Not Quite Love,$senderEND

Output:

Dear Spike, I wish you to leave Sunnydale and never return. Not Quite Love, Buffy the Vampire Slayer

Here is an example with single quotes:

print<<'END';Dear $recipient,I wish you to leave Sunnydale and never return.Not Quite Love,$senderEND

Output:

Dear $recipient, I wish you to leave Sunnydale and never return. Not Quite Love, $sender

And an example with backticks (may not be portable):

my$shell_script_stdout=<<`END`;echofooechobarEND

It is possible to start multiple heredocs on the same line:

say(<<BEGIN."this is the middle\n".<<END);Thisisthebeginning:BEGINAndnowitisover!END# this is equivalent to:say("This is the beginning:\nthis is the middle\nAnd now it is over!\n");

The tag itself may contain whitespace, which may allow heredocs to be used without breaking indentation.

say<<' END';HelloWorldEND

In addition to these strings, Perl also features file literals, namely the contents of the file following (formerly ) on a line by itself. This is accessible as the file object such as , and can be viewed as a form of data segment.

PHP[edit]

In PHP, here documents are referred to as heredocs.

<?php$name="Joe Smith";$occupation="Programmer";echo<<<EOF This is a heredoc section. For more information talk to $name, your local $occupation. Thanks!EOF;$toprint=<<<EOF Hey $name! You can actually assign the heredoc section to a variable!EOF;echo$toprint;?>

Outputs

This is a heredoc section. For more information talk to Joe Smith, your local Programmer. Thanks! Hey Joe Smith! You can actually assign the heredoc section to a variable!

The line containing the closing identifier must not contain any other characters, except an optional ending semicolon. Otherwise, it will not be considered to be a closing identifier, and PHP will continue looking for one. If a proper closing identifier is not found, a parse error will result at the last line of the script.[7]

In PHP 5.3 and later, like Perl, it is possible to not interpolate variables by surrounding the tag with single quotes; this is called a nowdoc:[8]

$x=<<<'END'Dear $recipient,I wish you to leave Sunnydale and never return.Not Quite Love,$senderEND;

In PHP 5.3+ it is also possible to surround the tag with double quotes, which like Perl has the same effect as not surrounding the tag with anything at all.

Ruby[edit]

The following Ruby code displays a grocery list by using a here document.

puts<<GROCERY_LISTGrocery list----1. Salad mix.2. Strawberries.*3. Cereal.4. Milk.** OrganicGROCERY_LIST

The result:

$ ruby grocery-list.rb Grocery list------------1. Salad mix.2. Strawberries.*3. Cereal.4. Milk.** Organic

The in a here document does not indicate input redirection, but Ruby also uses for input redirection, so redirecting to a file from a here document involves using twice, in different senses:

File::open("grocery-list","w")do|f|f<<<<GROCERY_LISTGrocery list----1. Salad mix.2. Strawberries.*3. Cereal.4. Milk.** OrganicGROCERY_LISTend

As with Unix shells, Ruby also allows for the delimiting identifier not to start on the first column of a line, if the start of the here document is marked with the slightly different starter "<<-". Besides, Ruby treats here documents as a double-quoted string, and as such, it is possible to use the #{} construct to interpolate code. The following example illustrates both of these features:

now=Time.nowputs<<-EOF It's #{now.hour} o'clock John, where are your kids? EOF

Ruby expands on this by providing the "<<~" syntax for omitting indentation on the here document:

puts<<~EOFThislineisindentedtwospaces.Thislineisindentedfourspaces.Thislineisindentedsixspaces.EOF

The common indentation of two spaces is omitted from all lines:

$ ruby indented-heredoc.rb This line is indented two spaces. This line is indented four spaces. This line is indented six spaces.

Like Perl, Ruby allows for starting multiple here documents in one line:

puts<<BEGIN+"<--- middle --->\n"+<<ENDThis is the beginning:BEGINAnd now it is over!END# this equals this expression:puts"This is the beginning:\n<--- middle --->\nAnd now it is over!"

As with Perl, Ruby features file literals, namely the contents of the file following on a line by itself. This is accessible as the file object and can be viewed as a form of data segment.

Others[edit]

Python[edit]

Python supports multi-line strings as a "verbatim" string.

print("""Customer: Not much of a cheese shop is it?Shopkeeper: Finest in the district , sir.""")

From 3.6, verbatim f-strings support variable and expression interpolation.

shop_type="CHEESE"accolade="finest"print(f"""Customer: Not much of a {shop_type.lower()} shop is it?Shopkeeper: {accolade.capitalize()} in the district , sir.""")

D[edit]

Since version 2.0, D has support for here document-style strings using the 'q' prefix character. These strings begin with followed immediately by a newline (for an arbitrary identifier IDENT), and end with at the start of a line.

intmain(){stringlist=q"IDENT1. Item One2. Item Two3. Item ThreeIDENT";writef(list);}

D also supports a few quoting delimiters, with similar syntax, with such strings starting with and ending with or similarly for other delimiter character (any of () <> {} or []).

OS/JCL[edit]

On IBM's Job Control Language (JCL) used on its earlier MVS and current z/OS operating systems, data which is inline to a job stream can be identified by an * on a DD statement, such as or In the first case, the lines of text follow and are combined into a pseudo file with the DD name SYSIN. All records following the command are combined until either another OS/JCL command occurs (any line beginning with ), the default EOF sequence () is found, or the physical end of data occurs. In the second case, the conditions are the same, except the DLM= operand is used to specify the text string signalling end of data, which can be used if a data stream contains JCL (again, any line beginning with ), or the sequence (such as comments in C or C++ source code). The following compiles and executes an assembly language program, supplied as in-line data to the assembler.

//AHARJOB('ALEX HARRIS')//EXECASMLG//SYSIN DD *APROG START XR 15,15 BR 14 END/*//* JOB ENDS

The statement is the functional equivalent of Indicating s stream of data follows, terminated by .

Racket[edit]

Racket's here strings start with followed by characters that define a terminator for the string.[9] The content of the string includes all characters between the line and a line whose only content is the specified terminator. More precisely, the content of the string starts after a newline following , and it ends before a newline that is followed by the terminator.

#lang racket(displayln#<<HERESTRINGThis is a simple here string in Racket. * One * Two * ThreeHERESTRING)

Outputs:

This is a simple here string in Racket. * One * Two * Three

No escape sequences are recognized between the starting and terminating lines; all characters are included in the string (and terminator) literally.

#lang racket(displayln#<<A here string in Racket ☺This string spans for multiple linesand can contain any Unicode symbol.So things like λ, ☠, α, β, are all fine.In the next line comes the terminator. It can contain any Unicode symbol as well, even spaces and smileys!A here string in Racket ☺)

Outputs:

This string spans for multiple lines and can contain any Unicode symbol. So things like λ, ☠, α, β, are all fine. In the next line comes the terminator. It can contain any Unicode symbol as well, even spaces and smileys!

Here strings can be used normally in contexts where normal strings would:

#lang racket(printf#<<ENDDear ~a,Thanks for the insightful conversation ~a. ~aEND"Isaac""yesterday""Carl")

Outputs:

Dear Isaac, Thanks for the insightful conversation yesterday. Carl

An interesting alternative is to use the language extension to write @-expressions.[10] They look like this:

(displayln @string-append{ This is a long string, very convenient when a long chunk of text is needed. No worries about escaping "quotes" or \escapes. It's also okay to have λ, γ, θ, ... Embed code: })

Outputs:

This is a long string, very convenient when a long chunk of text is needed. No worries about escaping "quotes" or \escapes. It's also okay to have λ, γ, θ, ... Embed code: 7

An @-expression is not specific nor restricted to strings, it is a syntax form that can be composed with the rest of the language.

Windows PowerShell[edit]

In Windows PowerShell, here documents are referred to as here-strings. A here-string is a string which starts with an open delimiter ( or ) and ends with a close delimiter ( or ) on a line by itself, which terminates the string. All characters between the open and close delimiter are considered the string literal. Using a here-string with double quotes allows variables to be interpreted, using single quotes doesn't. Variable interpolation occurs with simple variables (e.g. but NOT or ). You can execute a set of statements by putting them in (e.g. or ).

In the following PowerShell code, text is passed to a function using a here-string. The function is defined as follows:

PS > functionConvertTo-UpperCase($string){$string.ToUpper()}PS > ConvertTo-UpperCase@'>> one two three>> eins zwei drei>> '@ONE TWO THREEEINS ZWEI DREI

Here is an example that demonstrates variable interpolation and statement execution using a here-string with double quotes:

PS > $doc,$marty='Dr. Emmett Brown','Marty McFly'PS > $time=[DateTime]'Friday, October 25, 1985 8:00:00 AM'PS > $diff=New-TimeSpan-Minutes25PS > @">> $doc : Are those my clocks I hear?>> $marty : Yeah! Uh, it's $($time.Hour) o'clock!>> $doc : Perfect! My experiment worked! They're all exactly $($diff.Minutes) minutes slow.>> $marty : Wait a minute. Wait a minute. Doc... Are you telling me that it's $(($time+$diff).ToShortTimeString())?>> $doc : Precisely.>> $marty : Damn! I'm late for school!>> "@Dr. Emmett Brown : Are those my clocks I hear?Marty McFly : Yeah! Uh, it's 8 o'clock!Dr. Emmett Brown : Perfect! My experiment worked! They're all exactly 25 minutes slow.Marty McFly : Wait a minute. Wait a minute. Doc... Are you telling me that it's 08:25?Dr. Emmett Brown : Precisely.Marty McFly : Damn! I'm late for school!

Using a here-string with single quotes instead, the output would look like this: Output:

PS > @'>> $doc : Are those my clocks I hear?>> $marty : Yeah! Uh, it's $($time.Hour) o'clock!>> $doc : Perfect! My experiment worked! They're all exactly $($diff.Minutes) minutes slow.>> $marty : Wait a minute. Wait a minute. Doc... Are you telling me that it's $(($time + $diff).ToShortTimeString())?>> $doc : Precisely.>> $marty : Damn! I'm late for school!>> '@$doc : Are those my clocks I hear?$marty : Yeah! Uh, it's $($time.Hour) o'clock!$doc : Perfect! My experiment worked! They're all exactly $($diff.Minutes) minutes slow.$marty : Wait a minute. Wait a minute. Doc... Are you telling me that it's $(($time + $diff).ToShortTimeString())?$doc : Precisely.$marty : Damn! I'm late for school!

DIGITAL Command Language (DCL)[edit]

In DCL scripts, any input line which does not begin with a $ symbol is implicitly treated as input to the preceding command - all lines which do not begin with $ are here-documents. The input is either passed to the program, or can be explicitly referenced by the logical name SYS$INPUT (analogous to the Unix concept of stdin).

For instance, explicitly referencing the input as SYS$INPUT:

$ TYPE SYS$INPUTThis text will be directly echoedto the screen by the TYPE command.$! other commands ...

produces:

This text will be directly echoed to the screen by the TYPE command.

Additionally, the DECK command, initially intended for punched card support (hence its name: it signified the beginning of a data deck) can be used to supply input to the preceding command.[11] The input deck is ended either by the command $ EOD, or the character pattern specified by the /DOLLARS parameter to DECK.

Example of a program totalling up monetary values:

$ RUN ADD_SUMS.EXE $ DECK $13.53 $3.33 $2.33 $ EOD

Would produce the following output (presuming ADD_SUMS was written to read the values and add them):

Example of using DECK /DOLLARS to create one command file from another:

$ COPY SYS$INPUT SYS$SCRATCH:TEMP.COM $ DECK /DOLLARS=$$$$$ TYPE SYS$INPUTThis is an example of using DECK to createa command file from within a command file$$$$ $! other commands follow ...

See also[edit]

References[edit]

General[edit]

External links[edit]

  1. ^Note that while tabs can typically be entered in editors, at the command line they are typically entered by + + instead, due to tab completion, and in the example they are spaces, not tabs, so the example is cannot be copy and pasted.
  2. ^In more detail, in bash: “all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion. In the latter case, the character sequence \newline is ignored, and ‘\’ must be used to quote the characters ‘\’, ‘$’, and ‘`’.”, per 3.6.6 Here Documents. Note that has no special meaning in a here document and does not need to be escaped, unlike in a double-quoted string; otherwise they are essentially identical.
  3. ^“Quoting” includes escaping, so if is used, this is quoted, so variable interpolation does not occur, and it ends with , while if is used, this is quoted and ends with . This perhaps surprising behavior is however easily implemented in a shell, by the tokenizer simply recording a token was quoted (during the evaluation phase of lexical analysis), without needing to preserve the original, quoted value.
    One application is to use as the starting delimiter, and thus as the ending delimiter, which is similar to a multiline string literal but stripping starting and ending linebreaks.

0 thoughts on “Cat Eof Bash Variables Assignment”

    -->

Leave a Comment

Your email address will not be published. Required fields are marked *