Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

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 \\
share|improve this answer
    
This works! I think best solution here. Thank you for your answer! –  Masi 12 hours ago
    
I have some problem with the approach of the latest edit: # cat <<'EOF' start_tex \\ EOF gives error where start_tex is a simple file with some variables. Can you give an example how to use this EOF approach with catting file. My working case is just this cat start_tex - without variables, however. –  Masi 11 hours ago
1  
@Masi please edit your question then and clarify. You don't mention a file anywhere in your question. Try and make your questions as specific as possible. Anyway, you're looking for cat start_tex > out.tex which is much simpler. –  terdon 11 hours ago
1  
@Masi If the data are in a file, just use cat file in the usual way. The here document solution is used when the data are in the script, in a similar way to echo "[this thing]" (as in the question). Make sure that EOF is on its own line. –  vinc17 10 hours ago

My latex is not so good, do you set any variables in the text? Otherwise I would put the latex in an extra template file and just use cat to print it. This would make it more maintainable in case you want to replace the template one day.

share|improve this answer
1  
Welcome to Unix & Linux! This is really a comment, not an answer. Answers should only be used to provide actual answers not to ask for clarification. If you spend some more time on the site, you will gain sufficient privileges to leave comments on posts. In the meantime, I have converted your answer to a comment. –  terdon 11 hours ago
    
Can you add an example to your suggestion? It seems this solution is more abstract than it needs to be. –  HalosGhost 10 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.