Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

heredoc remove leading space tabs linux bash


You can change the here-doc operator to <<-. You can then indent both the here-doc and the delimiter with tabs:

#! /bin/bash
cat <<-EOF
    indented
    EOF
echo Done
Comment

heredoc remove leading space tabs linux bash


If you don't need command substitution and parameter expansion inside your here-document, you can avoid using tabs by adding the leading spaces to the delimiter:

$     cat << '    EOF'
>         indented
>     EOF
        indented
$     cat << '    EOF' | sed -r 's/^ {8}//'
>         unindented
>     EOF
unindented
Comment

heredoc remove leading space tabs linux bash

mail_content="Last Change: $dateLastChanged

    This is an automated warning of stale data for the UNC-G Blackboard Snapshot process."
    mailx -r "Systems and Operations <sysadmin@[redacted].edu>" -s "Warning Stale BB Data" jadavis6@[redacted].edu <<<"$mail_content"
Comment

heredoc remove leading space linux bash

usage () {
    # No tabs necessary!
    readarray message <<'    EOF'
        Hello, this is a cool program.
        This should get unindented.
        This code should stay indented:
            something() {
                echo It works, yo!;
            }
        That's all.
    EOF
    # Each line is indented an extra 8 spaces, so strip them
    printf '%s' "${message[@]#        }"
}
Comment

heredoc remove leading space tabs linux bash

sed 's/^ *//' >> ~/Desktop/text.txt << EOF
    Load time-out reached and nothing to resume.
    $(date +%T) - Transmission-daemon exiting.
EOF
Comment

PREVIOUS NEXT
Code Example
Shell :: Brave Beta on Fedora 28+, CentOS/RHEL 8+ 
Shell :: with great power comes great responsibility ubuntu 
Shell :: Collaborators access SSH new project Github 
Shell :: install auth0 
Shell :: how to clone databases on mongodb atlas 
Shell :: another command in awk field 
Shell :: how to create malware for android in kali 
Shell :: linux function return 
Shell :: git synchronize a branch in a fork 
Shell :: melpa .tar not found emacs 
Shell :: betterlock screen set wallpaper 
Shell :: kubuntu snap app not showing 
Shell :: left navbar not showing in ubuntu 
Shell :: update aur packages archlinux 
Shell :: How to redirect docker-compose command stdout stderr from docker container to file 
Shell :: connect db to odoo from command 
Shell :: view git pull changes terminal 
Shell :: How To Create Y/N Question On Batch Script 
Shell :: conda install nose2 
Shell :: phpstorm wsl scanning files to index very solw 
Shell :: printf 
Shell :: how to make a function in bash 
Shell :: fix merge conflict in package-lock.json 
Shell :: move a file from one directory to another in linux 
Shell :: committing on github 
Shell :: github create directory 
Shell :: sed match newline 
Shell :: installing docker compose on ec2 
Shell :: 1password cli install 
Shell :: create enumerated folders termina 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =