diff options
author | Madhusudan.C.S | 2011-06-10 23:19:59 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2011-06-10 23:19:59 +0530 |
commit | 9f2cb3128d19148fe1318e6122c41f4d98f5ae96 (patch) | |
tree | 71478e43f0b10a5e8a66392707def67c47e9dd01 | |
parent | 3e460d238465690e569610db3257d5a41c05f01c (diff) | |
parent | 8ac5a07c395f151e38ac29dfa51c14124d7ca901 (diff) | |
download | sees-9f2cb3128d19148fe1318e6122c41f4d98f5ae96.tar.gz sees-9f2cb3128d19148fe1318e6122c41f4d98f5ae96.tar.bz2 sees-9f2cb3128d19148fe1318e6122c41f4d98f5ae96.zip |
Merge branch 'master' of https://github.com/FOSSEE/sees
-rw-r--r-- | latex/slides.tex | 30 | ||||
-rw-r--r-- | ult/exercises.rst | 6 | ||||
-rw-r--r-- | ult/handout.rst | 44 | ||||
-rw-r--r-- | ult/ult.tex | 47 |
4 files changed, 97 insertions, 30 deletions
diff --git a/latex/slides.tex b/latex/slides.tex index c3470af..ea23cf4 100644 --- a/latex/slides.tex +++ b/latex/slides.tex @@ -99,7 +99,7 @@ \begin{frame} \frametitle{Course Outline} \begin{itemize} - \item Look at Sample document - \typ{sample.pdf} + \item Look at the sample document - \typ{sample.pdf} \begin{itemize} \item Title, Author, Date \item Abstract @@ -132,7 +132,7 @@ \begin{frame}[fragile] \frametitle{Typesetting a minimal document} \begin{itemize} - \item Write the sample code code into the file \typ{draft.tex}\\ + \item Write the sample code into the file \typ{draft.tex}\\ {\tiny See \typ{hg} rev0 of draft} \item To compile, (in terminal) \\ \begin{lstlisting}[language=bash] @@ -223,7 +223,7 @@ \begin{frame}[fragile] \frametitle{Abstract} \begin{itemize} - \item \typ{\\abstract} environment inserts abstract. + \item \typ{abstract} environment inserts abstract. \item Place it at the location where you want your abstract. \end{itemize} \tiny See rev3 of \typ{hg} @@ -277,13 +277,13 @@ \begin{frame}[fragile] \frametitle{Table of Contents [TOC]} \begin{itemize} - \item Our document is short, but let's learn to add a TOC. + \item Our document is short, but let's learn to add a TOC \item Add \lstinline{\tableofcontents} where you want TOC to - appear. - \item Compile. - \item Only headings appear. No page numbers. - \item A \lstinline{.toc} file is generated. - \item Re-compile. + appear + \item Compile + \item Only headings appear. No page numbers + \item A \lstinline{.toc} file is generated + \item Re-compile \item Any numbered section/block automatically appears \end{itemize} \tiny See rev8 of \typ{hg} @@ -369,7 +369,7 @@ \begin{itemize} \item Instead of using \lstinline{\texttt} we could use \lstinline{\verbatim} - \item \lstinline+\lstinline{listings}+ is a powerful package + \item \lstinline+listings+ is a powerful package \item \lstinline+\usepackage{listings}+ needs to be added \item Tell {\LaTeX} the language to be used, using \typ{\\lstset} \end{itemize} @@ -504,7 +504,7 @@ \begin{frame}[fragile] \frametitle{Math in \LaTeX} \begin{itemize} - \item Math is enclosed in a pair of \lstinline{$} signs of %%$ + \item Math is enclosed in a pair of \lstinline{$} signs or %%$ \lstinline+\( \)+ \item Used for typesetting inline Math. \item \lstinline+\usepackage{amsmath}+ @@ -516,9 +516,9 @@ \frametitle{Matrices} \begin{itemize} \item \lstinline+\bmatrix+ is used to typeset the matrix A - \item It works similar to ta tabular environment + \item It works similar to the tabular environment \item \lstinline+&+ for demarcating columns - \item \lstinline+\\+ for demwarcating rows + \item \lstinline+\\+ for demarcating rows \item Other matrix environments \begin{table} \center @@ -635,7 +635,7 @@ \item \lstinline+thebibliography+ environment provides a clean and simple way to add a bibliography to \LaTeX documents. \item \lstinline+\begin{thebibliography}+ takes as argument the - maximum with of the label that references will have. + maximum width of the label that references will have. \item Each item of the Bibliography is similar to an item in a list. \item \lstinline+\bibitem[label]{name}+ followed by the actual @@ -653,7 +653,7 @@ \frametitle{Beamer} \begin{itemize} \item Use beamer since your report's \LaTeX~ would be re-usable. - \item It is recommended to start with on of the beamer templates. + \item It is recommended to start with one of the beamer templates. \item Let's look at speaker introduction template. \item \lstinline+\documentclass{beamer}+ tells \LaTeX~ to start a beamer presentation. diff --git a/ult/exercises.rst b/ult/exercises.rst index b6be986..9898b39 100644 --- a/ult/exercises.rst +++ b/ult/exercises.rst @@ -57,7 +57,7 @@ Session-1 #. Change ownership of the file ``test`` to some other user (if exists). -#. Count the number of files in a directory. +#. Count the number of files (files, sub-directories, etc.) in a directory. #. Create a new file ``alice.txt`` by concatenating the first 30 lines and the last 40 lines of ``wonderland.txt``. @@ -73,7 +73,9 @@ Session-2 0. Read through the section ``REGULAR EXPRESSIONS`` in ``man grep`` -1. grep the marks of the students who scored above 75 in atleast one +#. Read through in ``man expr`` + +#. grep the marks of the students who scored above 75 in atleast one subject. #. grep the marks of all the students whose names begin with an 's' diff --git a/ult/handout.rst b/ult/handout.rst index b72dbdc..5ef762a 100644 --- a/ult/handout.rst +++ b/ult/handout.rst @@ -1785,6 +1785,41 @@ So, these are all the paths that are searched, when looking to execute a command. If we put the results.sh script in one of these locations, we could simply run it, without using the ``./`` at the beginning. +Variables +--------- + +As expected, it is possible to define our own variables inside our shell +scripts. For example, + +:: + + name="FOSSEE" + +creates a new variable ``name`` whose value is ``FOSSEE``. To refer to this +variable, inside our shell script, we would refer to it, as ``$name``. +**NOTE** that there is no space around the ``=`` sign. + +:: + + ls $name* + +It is possible to store the output of a command in a variable, by enclosing +the command in back-quotes. + +:: + + count=`wc -l wonderland.txt` + +saves the number of lines in the file ``wonderland.txt`` in the variable +count. + +Comments +-------- + +The ``#`` character is used to comment out content from a shell script. +Anything that appears after the ``#`` character in a line, is ignored by +the bash shell. + Control structures and Operators ================================ @@ -1910,6 +1945,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 62117eb..a94dc14 100644 --- a/ult/ult.tex +++ b/ult/ult.tex @@ -679,7 +679,7 @@ \begin{frame}[fragile] \frametitle{Redirection and Piping} \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ > /tmp/m_tmp.txt $ paste -d " " students.txt m_tmp.txt \end{lstlisting} % $ @@ -687,7 +687,7 @@ or \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - \end{lstlisting} % $ @@ -745,10 +745,10 @@ \item Error message is redirected, in the second case \end{itemize} \begin{lstlisting} - $ cut -d " " -c 2- marks.txt \ + $ cut -d " " -c 2- marks1.txt \ > /tmp/m_tmp.txt - $ cut -d " " -f 2- marks.txt 1> \ + $ cut -d " " -f 2- marks1.txt 1> \ /tmp/m_tmp.txt 2> /tmp/m_err.txt \end{lstlisting} % $ \begin{itemize} @@ -763,7 +763,7 @@ \begin{frame}[fragile] \frametitle{Piping} \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - \end{lstlisting} % $ \begin{itemize} @@ -852,7 +852,7 @@ \item Command below prints student marks, sorted by name \end{itemize} \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - \ | sort \end{lstlisting} % $ @@ -868,7 +868,7 @@ \item The command below sorts based on marks in first subject \end{itemize} \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt -\ | sort -t " " -k 2 -rn \end{lstlisting} % $ @@ -887,7 +887,7 @@ \item Command below searches \& shows the marks of Anne alone \end{itemize} \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - | grep Anne \end{lstlisting} % $ @@ -902,7 +902,7 @@ \item \texttt{-i} for case-insensitive searches \end{itemize} \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - | grep -i Anne \end{lstlisting} % $ @@ -911,7 +911,7 @@ \item To see everyone's marks except Anne's \end{itemize} \begin{lstlisting} - $ cut -d " " -f 2- marks.txt \ + $ cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - | grep -iv Anne \end{lstlisting} % $ @@ -989,7 +989,7 @@ \begin{lstlisting} #!/bin/bash mkdir ~/marks - cut -d " " -f 2- marks.txt \ + cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - \ | sort > ~/marks/results.txt \end{lstlisting} % $ @@ -1013,6 +1013,21 @@ \end{frame} \begin{frame}[fragile] + \frametitle{Variables \& Comments} + \begin{lstlisting} + $ name=FOSSEE + $ count=`wc -l wonderland.txt` + $ echo $count # Shows the value of count + \end{lstlisting} % $ + \begin{itemize} + \item It is possible to create variables in shell scripts + \item Variables can be assigned with the output of commands + \item \alert{NOTE:} There is no space around the \texttt{=} sign + \item All text following the \texttt{\#} is considered a comment + \end{itemize} +\end{frame} + +\begin{frame}[fragile] \frametitle{\texttt{echo}} \begin{itemize} \item \texttt{echo} command prints out messages @@ -1020,7 +1035,7 @@ \begin{lstlisting} #!/bin/bash mkdir ~/marks - cut -d " " -f 2- marks.txt \ + cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - \ | sort > ~/marks/results.txt echo "Results generated." @@ -1036,7 +1051,7 @@ \begin{lstlisting} #!/bin/bash mkdir ~/marks - cut -d " " -f 2- marks.txt \ + cut -d " " -f 2- marks1.txt \ | paste -d " " students.txt - \ | sort > ~/marks/$1 echo "Results generated." @@ -1211,6 +1226,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] |