정규식을 사용하여 이 의사코드를 작성하세요.

정규식을 사용하여 이 의사코드를 작성하세요.

저는 Crontab을 통해 매일 0230에 정기적으로 실행하는 Makefile을 작업하고 있습니다.

crontab -e; 30 2 * * * /bin/thePseudocode

Python과 유사한 의사 코드

directories = ["Cardiology", "Rheumatology", "Surgery"]
for directory in directories
   files = directory.files(); % not sure if such a parameter exists
   files = files.match(.*tex); % trying to get only tex files; not sure if match exists
   summaryFile = "";
   for texFile in files
      summaryFile.add( ...
                textFile.match( (?s)\\begin{question}.*?\\end{question} ) ...
      )
      % Solution based on this thread
      % Problem in writing this Regex in Perl http://unix.stackexchange.com/questions/159307/to-match-only-innermost-environment-by-regex
   end
end

save this `summaryFile` as /Users/Masi/Dropbox/QuestionSummary.tex

여기서 files는 디렉토리에 있는 모든 파일의 목록이고 는 summaryFile모든 tex 파일의 모든 문제를 나열하는 파일입니다. 결국 컴파일하고 싶은 파일PDF 라텍스매일 아침 PDF 리더로 읽으세요.

폴더에 있는 샘플 파일류마티스학

\section{Takayasu arteritis}

\begin{question}
{You get a patient. 
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}

\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye. 
So special eye diagnosis done. 
Affects eye.
\end{question}


Fever of unknown origin can be used when you do not know what is causing the disease. 

% Show cases in MedScape and ask class. 

Aneurysms. 


\subsection{Treatment}

\begin{question}
{What you should always include in Takayasu treatment? 
What are the symptoms?}
Blood pressure.
Aneurysms which will burst without treatment. 
So blood pressure decreasing drugs like beta blockers along in combination with other drugs.
\end{question}

\begin{question}
{When is the checkup of the Takayasu arteritis?} 
Only once per year. 
You could expect every month like normally in this kind of diseases.
But only once per year.
\end{question}

폴더의 모든 파일에 대한 출력이 있어야 하는 위치

\section{Rheumatology}

\begin{question}
{You get a patient. 
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}

\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye. 
So special eye diagnosis done. 
Affects eye.
\end{question}

\begin{question}
{What you should always include in Takayasu treatment? 
What are the symptoms?}
Blood pressure.
Aneurysms which will burst without treatment. 
So blood pressure decreasing drugs like beta blockers along in combination with other drugs.
\end{question}

\begin{question}
{When is the checkup of the Takayasu arteritis?} 
Only once per year. 
You could expect every month like normally in this kind of diseases.
But only once per year.
\end{question}

파일 생성

all: 
   pdflatex /Users/Masi/Dropbox/QuestionsSummary.tex /Users/Masi/Dropbox/QuestionsSummary.pdf
   pdflatex /Users/Masi/Dropbox/QuestionsSummary.tex /Users/Masi/Dropbox/QuestionsSummary.pdf % to compile a few times to be successful
pdflatex 
% I am not sure if I should have some error management, since often the pdflatex crashes
% So pdflatex is not probably the right tool to go

원하는 도구에서 이와 같은 의사 코드를 작성하는 방법은 무엇입니까? 나는 Python을 좋아하지만 전적으로 Python에 의존하지는 않습니다.

답변1

내가 올바르게 이해했다면 다음과 같은 것을 찾고 있는 것입니다(in bash).

#!/usr/bin/env bash

## avoid errors if a directory has no *tex files
shopt -s nullglob

directories=("Cardiology" "Rheumatology" "Surgery");

## Change this to set whichever options you want.
printf "%s\n%s\n" "\documentclass{YOURCLASS}" "\begin{document}"

for directory in ${directories[@]}
do
    ## Reset the counter, avoid empty sections.
    c=0;
    for file in "$directory"/*tex
    do
        let c++
        [ "$c" -eq 1 ] && printf "\n%s\n" "\section{$directory}"
        ## Extract the wanted lines
        perl -lne '$a=1 && print "" if /\\begin{question}/; 
                  print if $a==1;
                  $a=0 if /\\end{question}/;' "$file" 
        echo ""
    done
done
echo "\end{document}"

Cardiology 등이 포함된 디렉터리에서 스크립트를 실행하면 다음과 같은 출력이 제공되어야 합니다.

관련 정보