Horje
$(cat <<EOF  using heredoc assign command to a variable Code Example
$(cat <
1. Assign multi-line string to a shell variable
$ sql=$(cat <<EOF
SELECT foo, bar FROM db
WHERE foo='baz'
EOF
)
The $sql variable now holds the new-line characters too. You can verify with echo -e "$sql".

2. Pass multi-line string to a file in Bash
$ cat <<EOF > print.sh
#!/bin/bash
echo \$PWD
echo $PWD
EOF
The print.sh file now contains:

#!/bin/bash
echo $PWD
echo /home/user
3. Pass multi-line string to a pipe in Bash
$ cat <<EOF | grep 'b' | tee b.txt
foo
bar
baz
EOF
The b.txt file contains bar and baz lines. The same output is printed to stdout.

$(cat <
if true; then
    cat <<-EOF
    a
    EOF
fi
$(cat <
# Here Documents
This type of redirection instructs the shell to read input from the current source until a line containing only word (with no trailing blanks) is seen.
All of the lines read up to that point are then used as the standard input for a command.
The format of here-documents is

<<[-]word
    here-document
delimiter
$(cat <
cat <<-EOF
<tab>a
<tab>EOF
$(cat <
$ cat >> test <<HERE
> Hello world HERE <-- Not by itself on a separate line -> not considered end of string
> This is a test
>  HERE <-- Leading space, so not considered end of string
> and a new line
> HERE <-- Now we have the end of the string




Shell

Related
laravel mix Uncaught ReferenceError: babelHelpers is not defined Code Example laravel mix Uncaught ReferenceError: babelHelpers is not defined Code Example
Create subdomain | Nginx | Fish Shell Code Example Create subdomain | Nginx | Fish Shell Code Example
install avro for linux Code Example install avro for linux Code Example
multiple-gits Code Example multiple-gits Code Example
asdf check node version Code Example asdf check node version Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10