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 :: other-alternatives-of-column-command 
Shell :: Brave Beta on Fedora 28+, CentOS/RHEL 8+ 
Shell :: linux set global server name 
Shell :: node get git hash 
Shell :: get file info linux 
Shell :: install config split 
Shell :: invert 
Shell :: How to download Brave Browser in a chromebook 
Shell :: command line filters 
Shell :: syntax for ls 
Shell :: create json from console 
Shell :: save terminal history to file 
Shell :: terraform select workspace 
Shell :: powershell remove part of string 
Shell :: pre-recivice hook deline push gitlab 
Shell :: edit powershell profiles (linux) 
Shell :: Authenticate with a GitHub host. 
Shell :: git config --global user.email "you@example.com" 
Shell :: linux install certificate chain 
Shell :: Command to install parse-url module 
Shell :: git clone through ssh 
Shell :: how to clone repo with all branches 
Shell :: change git 
Shell :: linux compress a pdf 
Shell :: chown ubuntu 
Shell :: terraform VPC setup 
Shell :: git change commit message for merge 
Shell :: linx delete 
Shell :: count specific number in array powershell 
Shell :: error while installing DKphotogallery in xcode 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =