summaryrefslogtreecommitdiff
path: root/ult
diff options
context:
space:
mode:
authorPuneeth Chaganti2011-06-10 16:28:35 +0530
committerPuneeth Chaganti2011-06-10 16:28:35 +0530
commit638d6b456a95c64a71d0584a89404af1a1c2e8dd (patch)
treed867a1d64cfbf8ae5ac5a11d3a71942b9786e978 /ult
parent58630bcb4334866b399da831c72e32c6674cd996 (diff)
downloadsees-638d6b456a95c64a71d0584a89404af1a1c2e8dd.tar.gz
sees-638d6b456a95c64a71d0584a89404af1a1c2e8dd.tar.bz2
sees-638d6b456a95c64a71d0584a89404af1a1c2e8dd.zip
ult: Add content on shell variables and comments.
Diffstat (limited to 'ult')
-rw-r--r--ult/handout.rst35
-rw-r--r--ult/ult.tex15
2 files changed, 50 insertions, 0 deletions
diff --git a/ult/handout.rst b/ult/handout.rst
index a1ea9fb..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
================================
diff --git a/ult/ult.tex b/ult/ult.tex
index 613409f..a94dc14 100644
--- a/ult/ult.tex
+++ b/ult/ult.tex
@@ -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