summaryrefslogtreecommitdiff
path: root/ult
diff options
context:
space:
mode:
authorPuneeth Chaganti2011-06-09 15:47:48 +0530
committerPuneeth Chaganti2011-06-09 15:47:48 +0530
commit4932bba8c74ae8a0f027359f6ab5f03272cf3961 (patch)
treeec8c2e55a1c6e05ac9089b22ae6ecaaadc80ece7 /ult
parent3a8ee497d285d67302b468072b82727ac78ec4e0 (diff)
downloadsees-4932bba8c74ae8a0f027359f6ab5f03272cf3961.tar.gz
sees-4932bba8c74ae8a0f027359f6ab5f03272cf3961.tar.bz2
sees-4932bba8c74ae8a0f027359f6ab5f03272cf3961.zip
ult: Add exercises.
Diffstat (limited to 'ult')
-rw-r--r--ult/exercises.rst117
1 files changed, 59 insertions, 58 deletions
diff --git a/ult/exercises.rst b/ult/exercises.rst
index c5283a2..e130a0c 100644
--- a/ult/exercises.rst
+++ b/ult/exercises.rst
@@ -1,98 +1,87 @@
Session-1
=========
-1. What do you know about the GNU/Linux Naming controversy?
+1. Login to your machine from the CLI prompt, by pressing Ctrl+Alt+F1.
-#. ______ represents current directory
+#. Logout and re-login.
-#. ``./`` represents parent directory. T/F?
+#. What is your present working directory, once you login?
-#. The command ``PWD`` gives the present working directory. T/F?
+#. List all the files present in your current working directory.
-#. Directory names cannot have spaces in them. T/F?
+#. Navigate to the ``Desktop`` directory. If such a directory is not
+ present create one.
-#. _________ gives a quick description of the command, given it's name
+#. Navigate back to the ``home`` directory.
-#. _________ command is used to change present working directory
+#. Create a directory called ``ult`` inside another directory called
+ ``sees``. Create both the directories in a single command.
-#. _________ command is used to change present working directory
+#. What would be your present working directory after doing the
+ following?
-#. Explore the use of ``rmdir`` command.
+ ::
+
+ cd ~/sees/./../
-#. Read up about the root user and the ``sudo`` command.
+#. Use the touch command to create a file with your name in the
+ ``ult`` folder.
-Session-2
-=========
+#. Remove the file you created in the previous step.
-Elementary Regex
-----------------
+#. Navigate to your home directory and remove the directory
+ ``sees``. Use ``rm`` command.
-In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. A regular expression (often shortened to regex or regexp) is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.
+#. Re-create the directories ``sees`` and ``ult`` again. Now, remove
+ them using the ``rmdir`` command. Use ``man`` or ``--help``, if
+ required.
-Regular expressions are used by many text editors, utilities, and programming languages to search and manipulate text based on patterns. For example, Perl, Ruby and Tcl have a powerful regular expression engine built directly into their syntax. Several utilities provided by Unix distributions—including the editor *ed* and the filter *grep* — were the first to popularize the concept of regular expressions.
+#. Create a file with your first-name in your home directory and copy
+ it to ``sees/ult``.
+#. Copy the file again, but this time, ensure that ``cp`` checks if
+ such a file doesn't already exist.
-Regular Expressions are a feature of UNIX. They describe a pattern to match, a sequence of characters, not words, within a line of text. Here is a quick summary of the special characters used in the grep tool and their meaning:
+#. Copy the directory ``sees` to the directory ``sttp``.
-* ^ (Caret) = match expression at the start of a line, as in ^A.
-* $ (Question) = match expression at the end of a line, as in A$.
-* \ (Back Slash) = turn off the special meaning of the next character, as in \^.
-* [ ] (Brackets) = match any one of the enclosed characters, as in [aeiou].
- Use Hyphen "-" for a range, as in [0-9].
-* [^ ] = match any one character except those enclosed in [ ], as in [^0-9].
-* . (Period) = match a single character of any value, except end of line.
-* * (Asterisk) = match zero or more of the preceding character or expression.
-* \{x,y\} = match x to y occurrences of the preceding.
-* \{x\} = match exactly x occurrences of the preceding.
-* \{x,\} = match x or more occurrences of the preceding.
+#. Rename directory ``sttp`` with your name.
+#. Create a file ``test`` and modify its permission for user and group
+ to ``execute``.
+#. For the same ``test`` file, change mode to ``r,w,x`` for
+ all(user,group,others).
-Here are some examples using grep:
+#. Change ownership of the file ``test`` to some other user (if exists).
-* grep smug files {search files for lines with 'smug'}
-* grep '^smug' files {'smug' at the start of a line}
-* grep 'smug$' files {'smug' at the end of a line}
-* grep '^smug$' files {lines containing only 'smug'}
-* grep '\^s' files {lines starting with '^s', "\" escapes the ^}
-* grep '[Ss]mug' files {search for 'Smug' or 'smug'}
-* grep 'B[oO][bB]' files {search for BOB, Bob, BOb or BoB }
-* grep '^$' files {search for blank lines}
-* grep '[0-9][0-9]' file {search for pairs of numeric digits}
+#. Count the number of files in a directory.
-Lazy quantification
-~~~~~~~~~~~~~~~~~~~
+#. Create a new file ``alice.txt`` by concatenating the first 30 lines
+ and the last 40 lines of ``wonderland.txt``.
-The standard quantifiers in regular expressions are greedy, meaning they match as much as they can, only giving back as necessary to match the remainder of the regex. For example, someone new to regexes wishing to find the first instance of an item between < and > symbols in this example:
-::
+#. Show the lines from 10 to 20 of ``primes.txt``
- Another whale explosion occurred on <January 26>, <2004>.
+#. Concatenate the content of ``foo.txt`` and ``bar.txt`` in a single
+ ``foobar.txt`` but with the ``source:wikipedia`` line appearing only
+ once, at the end of the file.
-...would likely come up with the pattern <.*>, or similar. However, this pattern will actually return "<January 26>, <2004>" instead of the "<January 26>" which might be expected, because the `*` quantifier is greedy — it will consume as many characters as possible from the input, and "January 26>, <2004" has more characters than "January 26".
+Session-2
+=========
-Though this problem can be avoided in a number of ways (e.g., by specifying the text that is not to be matched: <[^>]*>), modern regular expression tools allow a quantifier to be specified as *lazy* (also known as non-greedy, reluctant, minimal, or ungreedy) by putting a question mark after the quantifier (e.g., <.*?>), or by using a modifier which reverses the greediness of quantifiers (though changing the meaning of the standard quantifiers can be confusing). By using a lazy quantifier, the expression tries the minimal match first. Though in the previous example lazy matching is used to select one of many matching results, in some cases it can also be used to improve performance when greedy matching would require more backtracking.
+0. Read through the section ``REGULAR EXPRESSIONS`` in ``man grep``
1. grep the marks of the students who scored above 75 in atleast one
subject.
-2. grep the marks of all the students whose names begin with an 's'
+#. grep the marks of all the students whose names begin with an 's'
-3. grep the marks of all the students whose names begin with
+#. grep the marks of all the students whose names begin with
consonants.
-4. generate a word frequency list for ``wonderland.txt``. Hint: use
-``grep``, ``tr``, ``sort``, ``uniq`` (or anything else that you
-want)
-
-5. change the results.sh script to accept the input files also as
+#. change the results.sh script to accept the input files also as
arguments.
-6. Show the lines from 10 to 20 of a file
-
-Session-3
-=========
-
-1. Write a shell script that will take a filename as input and check
+#. Write a shell script that will take a filename as input and check
if it is executable.
#. Modify the script in the previous step, to remove the execute
@@ -101,3 +90,15 @@ permissions, if the file is executable.
#. Write a shell script to remove all executable files from a
directory, when a directory is given as argument.
+#. List all the years between 2001 and 2099 which have 5 Fridays,
+ Saturdays and Sundays in the month of July. Hint: ``man cal``
+
+#. Generate frequency list of all the commands you have used, and show
+ the top 5 commands along with their count. (Hint: ``history`` command
+ will give you a list of all commands used.)
+
+#. generate a word frequency list for ``wonderland.txt``. Hint: use
+``grep``, ``tr``, ``sort``, ``uniq`` (or anything else that you want)
+
+#. **Print the middle line of a file**.
+