To wrap filecontents (Latex Source) between two tags.This has to be nested as shown.to add \begin{question}question.tex #This is Latex file with Question Source\begin{solution}Solution.tex  #This is latex source file for solution\end{solution}\end{question}My question seems to be not clear.  A little more as neededOut.txt should contain \begin{question}Contents of Question.tex File\begin{solution}Contents of Solution.tex file\end{solution}\end{question}I am a newbie to Bash scripting, please explain me how to do this. Contents of question.tex is a text with latex commands etc.  Similarly this is same with solution.tex
Script for wrapping LaTeX environments around texts from files
shell script;sed;latex
As don_crissti answered in the comments, I'll include it here to close the question out:{ printf %s\\n '\begin{question}';   cat Question.tex;   printf %s\\n '\begin{solution}';   cat Solution.tex;   printf %s\\n '\end{solution}' '\end{question}';} > Out.txt The braces open up a sequence of commands, all of whose output will get redirected into the Out.txt file. The printf statements simply print the associated text strings while the cat commands include the files Question.tex and Solution.tex.