Bash Script – How to Echo a Lot of Content

bashecho

I would like to do

echo "[this thing]"

This thing is

\documentclass{article}
\usepackage{rotating}
\usepackage{pdfpages}
\usepackage{verbatim}
\usepackage{amsmath, amsfonts, amssymb, textcomp, mathtools, xparse}
\usepackage[T4, OT1]{fontenc}
\usepackage{graphicx}
\graphicspath{{/Users/Masi/Dropbox/Physiology/images/}}
% Animations cannot be included here
% \addmediapath{ {/Users/Masi/Dropbox/Physiology/animations/} }
\usepackage{newunicodechar}
\usepackage{multirow}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\usepackage{color}
\usepackage{hyperref}
\usepackage{media9} % animations swf
\usepackage{Tabbing}
\usepackage{doi, natbib}
\hypersetup{
colorlinks=true,
linkcolor=blue,
citecolor=blue,
allcolors=blue
}
\usepackage[affil-it]{authblk}
\usepackage{import}
\usepackage{color}
\usepackage[normalem]{ulem}
\usepackage{titling} % Two titles in one document
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}


%%%%%%%%%%%%%%%%%%%%%%%%%%% Question and Answer %%%%%%%%%%%%%%%%%

\usepackage[framemethod=tikz]{mdframed}

\mdfdefinestyle{ans}{
  linecolor=cyan,
  backgroundcolor=yellow!20,
    frametitlebackgroundcolor=green!40,
    frametitlerule=true
}
\newcounter{question}[section]%
\setcounter{question}{0}

\newenvironment{question}[1]{%
\refstepcounter{question}%
    \begin{mdframed}[style=ans,frametitle={Question: #1}]
}{%
    \end{mdframed}%
}%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%% Smaller things

\newtheorem{case}{Case logic}
\mdfdefinestyle{que}{
  linecolor=cyan,
  backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{case}

\newtheorem{sidenote}{Sidenote}
\mdfdefinestyle{que}{
  linecolor=cyan,
  backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{sidenote}


\newtheorem{citation}{Citation}
\mdfdefinestyle{que}{
  linecolor=cyan,
  backgroundcolor=yellow!20,
}
\surroundwithmdframed[style=que]{citation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




\newtheorem{theorem}{Theorem}
\newtheorem{proposition}[theorem]{Proposition}
\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}] \emph}{\end{trivlist}}
\providecommand{\keywords}[1]{\textbf{Keywords:} #1}


%%%%%%%%%%%%%%%%%%%%%%%%% Counter Section %%%%%%%%%%%%%%%%%%%%%%
\makeatletter
  \def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
    \fi
    \addcontentsline{toc}{part}{#1}%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \LARGE \bfseries #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\@addtoreset{section}{part}    
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

How can you echo such a big content in Bash file well?

Best Answer

Use a here document:

cat <<'EOF'
Data...
EOF

Note: it's better to quote the heredoc word (EOF) as above to avoid expansion if the data contains something like $foo or backslashes, unless you want expansion of course. Examples:

$ cat <<EOF
$SHLVL \\
EOF

gives something like:

3 \

while

$ cat <<'EOF'
$SHLVL \\
EOF

gives:

$SHLVL \\
Related Question