diff options
Diffstat (limited to 'ult')
-rw-r--r-- | ult/handout.rst | 9 | ||||
-rw-r--r-- | ult/ult.tex | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/ult/handout.rst b/ult/handout.rst index b72dbdc..a1ea9fb 100644 --- a/ult/handout.rst +++ b/ult/handout.rst @@ -1910,6 +1910,15 @@ dummy or a loop variable. It can then be used to refer to the element of the list that is currently being dealt with. We could, obviously, use something as lame as ``i`` in place of ``animal``. +To generate a range of numbers and iterate over them, we do the following. + +:: + + for i in {5..10} + do + echo $i + done + Now, we use a ``for`` loop to list the files that we are interested in. :: diff --git a/ult/ult.tex b/ult/ult.tex index e1feb3d..613409f 100644 --- a/ult/ult.tex +++ b/ult/ult.tex @@ -1211,6 +1211,12 @@ \item Loop over the list; \texttt{animal} is a dummy variable \item Echo value of \texttt{animal} --- each name in list \end{itemize} + \begin{lstlisting} + for i in {10..20} + do + echo $i + done + \end{lstlisting} % $ \end{frame} \begin{frame}[fragile] |