Skip to content

Commit 96302dd

Browse files
author
sushant
committed
Initial repo, laptop cleanup
0 parents  commit 96302dd

File tree

870 files changed

+238821
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

870 files changed

+238821
-0
lines changed

bash/Bash Exercises.html

+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML//EN">
2+
<html><head>
3+
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
4+
<title>Bash Exercises</title>
5+
<style>
6+
ol.a
7+
{
8+
list-style-type:lower-alpha;
9+
}
10+
h2
11+
{
12+
color:red;
13+
}
14+
h3 {color:blue;}
15+
table {border:solid;}
16+
td {border:solid;}
17+
.em { color:red; font-weight:bold }
18+
</style>
19+
</head>
20+
21+
<body>
22+
<h2>Bash Exercises</h2>
23+
24+
<p>Some of the exercises below are <span class="em">optional</span>
25+
carrying <span class="em">house points</span>. You need not have to
26+
submit these as part of your mandatory exercises. The house points
27+
for these optional exercises are <span class="em">counted once per
28+
house</span>, and will count against the name of the student
29+
submitting the earliest. Note that you have to submit all exercises
30+
at once: so it will be better for your house if different members
31+
submit different optional parts.</p>
32+
33+
<p>Of course I encourage everyone to try all the exercises at leisure,
34+
or at least learn the solutions from colleagues, after the submission
35+
deadline.</p>
36+
37+
<h3>Bash file templates</h3>
38+
39+
<p>For each exercise, you are given a bash file template. Edit this
40+
template for your solution. In each case, the details of what you are
41+
supposed to do in the script is given in the template file. This is
42+
inculcate in you the habit of documenting a script as part of the
43+
script itself, through appropriate comments. This is also how future
44+
exams (in bash) will appear.</p>
45+
46+
<h3>Test cases (coming up)</h3>
47+
48+
<p>In some cases, test input and the expected output for the test
49+
input is given. Check against these. Again, future exams (in bash)
50+
will follow this format: while evaluating, I will use a script against
51+
one or more test inputs.</p>
52+
53+
<h3>Submission instructions (coming up)</h3>
54+
55+
<p>You are given the script prepare-upload.sh which will do the
56+
obvious. Upload the tgz file resulting from this to moodle as your
57+
submission.</p>
58+
59+
<ol>
60+
<li>Simple sequence of commands, simple if-then-else:
61+
<ol class="a">
62+
<li><b>tex2pdf.sh</b>
63+
Script to generate dvi from latex file,
64+
and tar the entire directory.
65+
<br>
66+
<i>Concepts exercised:</i> script as a sequence of commands
67+
</li><li><b>tex2pdf-a.sh</b>
68+
Script to generate dvi from latex file,
69+
and tar the entire directory, taking one argument.
70+
<br>
71+
<i>Concepts exercised:</i> command line argument
72+
</li><li><b>tex2pdf-b.sh</b>
73+
Script to generate dvi from latex file,
74+
and tar the entire directory, taking one argument. Check
75+
latex compilation success. <i>Hint</i> Learn the use of
76+
the special shell variable "$?".
77+
<br>
78+
<i>Concepts exercised:</i> checking command exit status,
79+
if-then-else
80+
</li><li><span class="em">Optional [5HP]:</span>
81+
<b>tex2pdf-c.sh</b>
82+
Script to generate dvi from latex file from any location
83+
and tar the entire directory from the parent directory, taking one argument. Check
84+
latex compilation success. <i>Hint</i> Learn the use of
85+
pwd, dirname, and basename; perhaps also pushd and popd.
86+
<br>
87+
<i>Concepts exercised:</i> Learning to change directories
88+
using pushd and popd,
89+
getting the working directory, dirname, and basename.
90+
</li><li><b>tcd.sh</b> Timed cd.
91+
<br>
92+
<i>Concepts exercised:</i> if-then-else, combining conditionals
93+
</li>
94+
<li><b>myopen.sh</b>
95+
This script opens a file using the right program.
96+
<br>
97+
<i>Concepts exercised:</i> if-then-else, string manipulation
98+
</li>
99+
<li><span class="em">Optional [1HP]:</span>
100+
<b>myopen-a.sh</b>
101+
This script opens a file using the right program, and can
102+
handle sophisticated extension possibilities
103+
<br>
104+
<i>Concepts exercised:</i> if-then-else, string manipulation
105+
</li>
106+
</ol>
107+
</li>
108+
<li>Involving loops:
109+
<ol class="a">
110+
<li><b>photo-rename.sh</b>
111+
Write a bash script called photo-rename.sh to rename, in a given
112+
directory, all files of the form ddmmyyyyANY.jpg to
113+
yyyy-mm-dd-ANY.jpg<br>
114+
Here, 'dd', 'mm', 'yyyy' correspond to the two digit date, two
115+
digit month, and four digit year when the photo was taken, and
116+
'ANY' corresponds to any string (including the empty string, it
117+
may include spaces).
118+
The first three fields fields consist only of digits 0 to 9.<br>
119+
Your script should ignore jpg files which are not of the form
120+
ddmmyyyyANY.jpg<br>
121+
Your script should take the directory name as argument; if no
122+
argument is given, it must print the usage and exit with exit
123+
value 1. If the given argument does not correspond to a
124+
directory, the script must exit with exit value 2.<br>
125+
<br>
126+
<i>Concepts exercised:</i> loops, learning to handle
127+
spaces in file/dir names
128+
</li>
129+
<li><b>myopen-generic.sh</b>
130+
This is an enhancement to myopen.sh, making it more
131+
generic.
132+
<br>
133+
<i>Concepts exercised:</i> simple I/O redirection, string manipulation
134+
</li>
135+
<li><span class="em">Optional [1HP]:</span>
136+
<b>myopen-generic-a.sh</b>
137+
The configuration file should by default be myopen.cfg in the
138+
home directory. Your script should support overriding this default
139+
with an environment variable MYOPENCFG; if this environment variable
140+
is set, its value should be taken as the configuration file.
141+
<br>
142+
<i>Concepts exercised:</i> use of environment variables
143+
</li>
144+
</ol>
145+
</li>
146+
<li>Involving pipes:
147+
<ol class="a">
148+
<li><b>photo-dates.sh</b>
149+
Script to print the date and time of a photo.
150+
<br>
151+
<i>Concepts exercised:</i> simple use of pipe
152+
</li>
153+
<li><span class="em">Optional [2HP]:</span>
154+
<b>photo-dates-a.sh</b>
155+
Script to print the date and time of several photos.
156+
<br>
157+
<i>Concepts exercised:</i> simple use of pipe, loops,
158+
string manipulation
159+
</li>
160+
<li><b>get-ip.sh</b>
161+
Script to get the IP address of your machine.
162+
<br>
163+
<i>Concepts exercised:</i> simple use of pipe
164+
</li>
165+
<li><span class="em">Optional [2HP]:</span>
166+
<b>get-ip-a.sh</b>
167+
Script to print only the IP address of your machine.
168+
<br>
169+
<i>Concepts exercised:</i> simple use of pipe, string
170+
manipulation
171+
</li>
172+
<li><b>num-uploaded.sh</b>
173+
Script to find out how many students have submitted their
174+
bash assignment so far.
175+
<br>
176+
<i>Concepts exercised:</i> use of pipe
177+
</li>
178+
<li><span class="em">Optional [10HP]:</span>
179+
<b>tar-scp.sh</b>
180+
Script to tar and copy the result to another machine,
181+
WITHOUT creating any file, in a SINGLE LINE command.
182+
<br>
183+
<i>Concepts exercised:</i> forcing tar to output to
184+
stdout, using ssh to execute a command, use of pipe
185+
</li>
186+
</ol>
187+
</li>
188+
<li>Involving sed, awk: (coming up)
189+
</li>
190+
</ol>
191+
192+
<hr>
193+
<address>Bhaskaran Raman</address>
194+
<!-- hhmts start -->
195+
Last modified: Sat Aug 31 08:41:57 IST 2013
196+
<!-- hhmts end -->
197+
198+
</body></html>

bash/Bash Exercises_files/style.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2+
<html><head>
3+
<title>404 Not Found</title>
4+
</head><body>
5+
<h1>Not Found</h1>
6+
<p>The requested URL /cs699/style.css was not found on this server.</p>
7+
<hr>
8+
<address>Apache/2.2.22 (Ubuntu) Server at shadowfax.cse.iitb.ac.in Port 80</address>
9+
</body></html>

bash/exercise-template.tgz

1.85 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# This script should take exactly one argument, a file. It should
4+
# invoke emacs on the file if the file has a txt extension. It should
5+
# invoke firefox on the file if the file has a html extension. It
6+
# should invoke evince on the file if the file has a pdf extension.
7+
# It should exit reporting error if the file has no extension or if it
8+
# has some other extension. The script should handle arguments which
9+
# have multiple '.' characters. For example, the extension for file
10+
# a.b.txt is 'txt'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# This script should take exactly one argument, a file. It should
4+
# invoke emacs on the file if the file has a txt extension. It should
5+
# invoke firefox on the file if the file has a html extension. It
6+
# should invoke evince on the file if the file has a pdf extension.
7+
# It should exit reporting error if the file has no extension or if it
8+
# has some other extension
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\relax
+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=latex 2013.7.24) 28 AUG 2013 17:04
2+
entering extended mode
3+
%&-line parsing enabled.
4+
**paper.tex
5+
(./paper.tex
6+
LaTeX2e <2009/09/24>
7+
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
8+
yphenation, loaded.
9+
10+
! LaTeX Error: File `plain.cls' not found.
11+
12+
Type X to quit or <RETURN> to proceed,
13+
or enter new name. (Default extension: cls)
14+
15+
Enter file name:
16+
! Interruption.
17+
<to be read again>
18+
}
19+
l.2 \author
20+
{Sushant Mahajan}^^M
21+
?
22+
No file paper.aux.
23+
\openout1 = `paper.aux'.
24+
25+
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5.
26+
LaTeX Font Info: ... okay on input line 5.
27+
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5.
28+
LaTeX Font Info: ... okay on input line 5.
29+
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5.
30+
LaTeX Font Info: ... okay on input line 5.
31+
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5.
32+
LaTeX Font Info: ... okay on input line 5.
33+
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5.
34+
LaTeX Font Info: ... okay on input line 5.
35+
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5.
36+
LaTeX Font Info: ... okay on input line 5.
37+
38+
! LaTeX Error: The font size command \normalsize is not defined:
39+
there is probably something wrong with the class file.
40+
41+
See the LaTeX manual or LaTeX Companion for explanation.
42+
Type H <return> for immediate help.
43+
...
44+
45+
l.5 \begin{document}
46+
47+
?
48+
! Undefined control sequence.
49+
l.6 \maketitle
50+
51+
?
52+
! Undefined control sequence.
53+
l.8 \section
54+
{Simple Section}
55+
?
56+
Missing character: There is no S in font nullfont!
57+
Missing character: There is no i in font nullfont!
58+
Missing character: There is no m in font nullfont!
59+
Missing character: There is no p in font nullfont!
60+
Missing character: There is no l in font nullfont!
61+
Missing character: There is no e in font nullfont!
62+
Missing character: There is no S in font nullfont!
63+
Missing character: There is no e in font nullfont!
64+
Missing character: There is no c in font nullfont!
65+
Missing character: There is no t in font nullfont!
66+
Missing character: There is no i in font nullfont!
67+
Missing character: There is no o in font nullfont!
68+
Missing character: There is no n in font nullfont!
69+
70+
! LaTeX Error: The font size command \normalsize is not defined:
71+
there is probably something wrong with the class file.
72+
73+
See the LaTeX manual or LaTeX Companion for explanation.
74+
Type H <return> for immediate help.
75+
...
76+
77+
l.10 \end{document}
78+
79+
? X
80+
81+
Here is how much of TeX's memory you used:
82+
14 strings out of 495062
83+
426 string characters out of 1182644
84+
45108 words of memory out of 3000000
85+
3287 multiletter control sequences out of 15000+50000
86+
3948 words of font info for 15 fonts, out of 3000000 for 9000
87+
28 hyphenation exceptions out of 8191
88+
22i,2n,15p,58b,97s stack positions out of 5000i,500n,10000p,200000b,50000s
89+
No pages of output.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
\documentclass{plain}
2+
\author{Sushant Mahajan}
3+
\date{28th August, 2013}
4+
\title{Tex2Pdf}
5+
\begin{document}
6+
\maketitle
7+
\newpage
8+
\section{Simple Section}
9+
\textbf{This converts to bold}
10+
\end{document}
11+
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Timed cd
4+
5+
# A student has 3 lab courses: CS599, CS699, CS799 with the following
6+
# schedule:
7+
# CS599: Mon 2-5pm
8+
# CS699: Wed 2-5pm
9+
# CS799: Fri 2-5pm
10+
# The student has 3 sub-directories CS599, CS699, CS799 in the current
11+
# directory
12+
13+
# Write a script to take two arguments:
14+
# Argument-1: day of the week in 3-letter capitalized format
15+
# (e.g. Wed, Fri, Sat, etc.)
16+
# Argument-2: hour of the day in 24-hour format (0-23)
17+
# The script should change directory to the correct directory
18+
# depending on the time
19+
# The script should print an appropriate error message if it does not
20+
# get exactly two arguments
21+
# If the time window does not match any of the lab timings, then the
22+
# script should not change directory
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#/bin/bash
2+
3+
# This program should compile the latex file given as argument, a tex
4+
# file assumed to be in the current/working directory. And it should
5+
# tar-gzip the entire current directory (from the current directory)
6+
# to a tgz file called paper.tgz. It should then move the paper.tgz
7+
# file to /tmp.
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#/bin/bash
2+
3+
# This program should compile the latex file given as argument, a tex
4+
# file assumed to be in the current/working directory. And if the
5+
# latex compilation succeeds, it should tar-gzip the entire current
6+
# directory (from the current directory) to a tgz file called
7+
# paper.tgz. It should then move the paper.tgz file to /tmp.
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#/bin/bash
2+
3+
# This program should compile the latex file given as argument. The
4+
# tex file can be in any directory; its full path name or relative
5+
# path name may be given as argument. And if the latex compilation
6+
# succeeds, it should tar-gzip the entire directory in which the latex
7+
# file resides, from the parent directory, to a tgz file. The name of
8+
# the tgz file should be <dirname>.tgz where <dirname> is the name of
9+
# the directory in which the latex file resides. It should then move
10+
# the tgz file to /tmp.

0 commit comments

Comments
 (0)