\documentclass[10pt]{ictlabtest}
%\documentclass[10pt]{ictlabtest}
\usepackage{rcs,multicol}

\RCS $Revision: 1.0 $


%\usepackage[screen,margin=4mm,centering]{geometry}
%\usepackage{calc,acro,alltt,key,xr,nick,color,multicol}
\usepackage{xr,color,alltt}
%\geometry{left=10mm, right=10mm}
\externaldocument[lt-]%
{../../linux_training-plus-config-files-ossi/build/masterfile}

\usepackage[pdfpagemode=None,pdfauthor={Nick Urbanik}]{hyperref}

\newcommand*{\labTitle}{Quiz 7: Shell Programming}
\renewcommand*{\subject}{Operating Systems and Systems Integration}

\providecommand*{\RPM}{\acro{RPM}\xspace}
\providecommand*{\CD}{\acro{CD}\xspace}

%\setlength{\paperwidth}{260mm}
%\setlength{\paperheight}{310mm}

\makeatletter
\renewcommand\theenumii{\@Alph\c@enumii}
\makeatother
%\newcommand*{\margin}{5mm}
%\renewcommand*{\slideleftmargin}{\margin}
%\renewcommand*{\sliderightmargin}{\margin}
%\renewcommand*{\slidetopmargin}{\margin}
%\renewcommand*{\slidetopmargin}{\margin}
%\renewcommand*{\slidebottommargin}{\margin}
%\renewcommand*{\slidetopmargin}{0pt}
%\renewcommand*{\slidebottommargin}{-50pt}

% Do not set paperwidth or paperheight.

%\setlength{\slidewidth}{297mm-2\margin}
%\setlength{\slideheight}{210mm-2\margin}
%\setlength{\slideheight}{210mm}

%\slideframe[]{none}
%\setlength{\slideframesep}{0pt}
%\slidesmag{2}
%\setcounter{finalcolumnbadness}{10000}
%\setcounter{columnbadness}{10000}

\definecolor{light-blue}{rgb}{0.4,0.4,1}
\newcommand*{\gl}[1]{\textcolor{light-blue}{#1}} % good link
\newcommand*{\ex}[1]{\textcolor{green}{#1}} % executable file
\newcommand*{\bl}[1]{\colorbox{red}{\textcolor{white}{\textbf{#1}}}} % bad link

\begin{document}
%% \raggedright
%% \pagestyle{empty}
%% %\Large
%% %\tableofcontents
%% %\begin{slide}
%% \begin{center}
%%   \par\vspace*{\fill}\par
%%   \begin{minipage}[c]{0.99\linewidth}
%%     \centering {\Huge\sffamily\bfseries Any marks not recognised by
%%       the Optical Mark Recognition (OMR) machine will get ZERO marks
%% \par\vspace*{0.1\textheight}\par
%% Correct mistakes with an eraser, correction pen or white tape; it is
%% not enough to put a cross through the circle
%% \par\vspace*{0.1\textheight}\par
%% Errors in student number get ZERO marks}
%%   \end{minipage}
%%   \par\vspace*{\fill}\par
%% \end{center}
%% \clearpage
%% %\par\vspace*{-15mm}\par
%%   \begin{center}
%% \bfseries
%% {\Large Operating Systems and Systems Integration \  Quick Quiz 3}
%%   \end{center}

\noindent%
\textbf{Do not refer to any printed material.\\  No talking or discussion is
allowed until the answer sheets are all collected.}
%\extraslideheight{0pt}
%\enlargethispage*{2\baselineskip}
%\large%
%\begin{multicols}{2}
%\setcounter{columnbadness}{10000}
%\setcounter{unbalance}{2}
\paragraph{Review:}


\begin{enumerate}
  \item Here are two arithmetic conditions that are to be used with an
    \texttt{if} statement:
\begin{verbatim}
[ $i -lt 5 ]                          ((i<5))
\end{verbatim}%$
  \begin{enumerate}
  \item Both are correct
  \item The first is correct but the second is not because the
  `\texttt{\$}' is missing before the `\texttt{i}'
\item The first is correct but the second is not because there should
  be spaces between the tokens
  \item The first is correct but the second is not correct because the
    operator should be `\texttt{-lt}'
  \item The first is wrong, but the second is correct.
  \end{enumerate}
  
\item Which of the following will cause a shell variable \texttt{var} to
  be defined with the value ``\texttt{value}''?
  \begin{enumerate}
  \item
\begin{alltt}
$ \textbf{$var=$\{value\}}
\end{alltt}%$
  \item
\begin{alltt}
$ \textbf{$var = value}
\end{alltt}
  \item
\begin{alltt}
$ \textbf{var = value}
\end{alltt}%$
  \item
\begin{alltt}
$ \textbf{var=value}
\end{alltt}%$
  \item
\begin{alltt}
$ \textbf{$var=value}
\end{alltt}
  \end{enumerate}

\item A shell script \texttt{script.sh} is executed like this, and the
  output is shown:
\begin{alltt}
$ \textbf{script.sh 1 2 3 4 5 6}
parameters are 1 2 3 4 5 6
\end{alltt}%$
  The first line of the file \texttt{script.sh} is
  \texttt{\#!~/bin/sh} \ The second line could be:
  \begin{enumerate}
  \item
\begin{alltt}
$ \textbf{parameters are $* $2 $3 $4 $5 $6}
\end{alltt}
  \item
\begin{alltt}
$ \textbf{echo parameters are $0 $1 $2 $3 $4 $5}
\end{alltt}
  \item
\begin{alltt}
$ \textbf{echo parameters are $# $1 $2 $3 $4 $5}
\end{alltt}%$
  \item
\begin{alltt}
$ \textbf{echo parameters are $\textnormal{\textbf{@}}}
\end{alltt}
  \item
\begin{alltt}
$ \textbf{echo parameters are $$ $1 $2 $3 $4 $5}
\end{alltt}%$
  \end{enumerate}


%% \item the directory \texttt{/proc} contains information that is:
%%   \begin{enumerate}
%%   \item dynamic information about the OS and hardware
%%   \item a type of relational database; SQL is always used to query it
%%   \item a list of network \textbf{proc}ters
%%   \item is unreadable except by the OS kernel
%%   \item contains entirely static data that is fixed when the computer
%%     boots 
%%   \end{enumerate}
\end{enumerate}

\vspace*{-5mm}

\paragraph{Preparation:}

\begin{enumerate}
\setcounter{enumi}{3}
\item This question relates to input and output in the shell:
  \begin{enumerate}
  \item We can perform \emph{input} with \texttt{read}, \emph{output}
    with \texttt{printf}
  \item We can perform \emph{input} with \texttt{read}, \emph{output}
    with \texttt{echo}
  \item We often use a \texttt{while} loop with \texttt{read} to
    process \emph{input}, one line for each iteration of the loop
  \item We use \emph{redirection} to put output into files
  \item All the other choices are correct
  \end{enumerate}

\item A shell script is written called \texttt{rename}.  It can be
  called in any of the following ways:
\vspace*{-2ex}
  \begin{multicols}{3}
\begin{alltt}
$ \textbf{rename}
$ \textbf{rename -v}
$ \textbf{rename -v *.c}
$ \textbf{rename -v *.c}
$ \textbf{rename -v -l *.c}
\end{alltt}%$
The `\texttt{-v}', `\texttt{-l}' are called:
\begin{enumerate}
\item \emph{enumerations}
\item \emph{test fields}
\item \emph{parameters}
\item \emph{param}
\item \emph{options}
\end{enumerate}
\end{multicols}

%% \item Functions in the shell:
%%   \begin{enumerate}
%%   \item are not \emph{actual} functions, but are separate shell
%%     scripts that are loaded at run time
%%   \item are not supported in version~2.x of Bash;
%%   \item are less useful than in other programming languages
%%   \item Cannot accept function parameters
%%   \item Do not start a new process
%%   %\item are not used as much as \emph{shell objects}
%%   \end{enumerate}
\end{enumerate}
%\end{multicols}
%\end{slide}
\end{document}
