diff options
author | Puneeth Chaganti | 2011-06-10 16:28:14 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2011-06-10 16:28:14 +0530 |
commit | 58630bcb4334866b399da831c72e32c6674cd996 (patch) | |
tree | 2942ed760c98ddaf7cebe478ebeece429599f650 | |
parent | d305a9b065ad24fdae0da47a6d8a7140cd8e0a43 (diff) | |
download | sees-58630bcb4334866b399da831c72e32c6674cd996.tar.gz sees-58630bcb4334866b399da831c72e32c6674cd996.tar.bz2 sees-58630bcb4334866b399da831c72e32c6674cd996.zip |
ult: Add example for iterating over range of numbers.
-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] |