Skip to content

Commit 4faae19

Browse files
committed
Checked all tasks. Verification on Docker pending.
1 parent a6d068d commit 4faae19

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

Task-1/roman.sh

100644100755
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/bin/bash
22

3+
# Task 1.C
34
# VARIABLE DESCRIPTION
45
## R : Roman numeral
56
## C : "Checkpoint", hardcoded values where the "pattern" for roman numerals changes
67
## n : Local variable for N
78
## D2R : Function that finds the number of occurances (F) of a checkpoint in a given number and prints it F times , for example, D2R(34,10,X) gives the answer as XXX as F = 3
89
## F : No. of occurances of a checkpoint in N
910
## K and V : (Key and Value) Decimal to Roman mapping for the checkpoints
10-
11+
#
1112
N=$1
12-
13+
#
1314
D2R()
1415
{
1516
n=$1
@@ -21,15 +22,16 @@ D2R()
2122
do
2223
echo -n $R
2324
((F--))
24-
done
25+
done
2526
return $n
2627
}
27-
28+
#
2829
K=(100 90 50 40 10 9 5 4 1)
2930
V=(C XC L XL X IX V IV I)
30-
31+
#
3132
for i in {0..8}
32-
do
33+
do
3334
D2R $N ${K[$i]} ${V[$i]}
3435
N=$?
35-
done
36+
done
37+
#

Task-1/sum.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ then
1111
else
1212
echo 'Wrong number of arguments, expected 2'
1313
exit 1
14-
fi
14+
fi

Task-1/sum_all.sh

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ then
1111
else
1212
SUM=0
1313
for (( i=1; i<=$N_ARGS; i++))
14-
do
14+
do
1515
SUM=$(./sum.sh $SUM ${!i})
1616
done
1717
echo $SUM
1818
exit 0
19-
fi
19+
fi

Task-2/cipher.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
# Task 2
4+
35
if [ $# -eq 0 ]
46
then
57
echo "Usage: ./cipher.sh <url>"
@@ -39,7 +41,6 @@ done
3941

4042
cat encrypted.txt | tr $TRANSLATION $ALPHABETS > deciphered.txt # Store the deciphered letter in 'deciphered.txt'
4143

42-
echo "PS. Give me the names." | tr $ALPHABETS $TRANSLATION >> encrypted.txt # Encrypt and append the line to encrypted.txt
44+
echo "PS. Give me the names." | tr $ALPHABETS $TRANSLATION >> encrypted.txt # Encrypt and append the line to encrypted.txt
4345

4446
exit 0
45-

Task_3/verifier.sh renamed to Task-3/verifier.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/bin/bash
2+
3+
# Task 3
4+
15
if [ $# -ne 3 ]; then # '$#' gives the number of command line args supplied
26
echo 'Usage: ./verifier.sh <source file> <testcases url> <cut-dirs arg>'
37
exit 1 # Exit if the number of arguments aren't 3.

Task-4/organiser.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/bin/bash
2+
3+
# Task 4
4+
15
# Create required base directories
26
mkdir -p playlists albums
37

Task-5/story.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ OUT=$3 # Path to the output file
88
> $OUT # Clears the contents of the output file first
99

1010
while [ 1 ]
11-
do
12-
# Find $KEY recursively in $DIR and using `-n` show the line number too.
11+
do
12+
# Find $KEY recursively in $DIR and using `-n` show the line number too.
1313
# (Note: Line numbers are shown as ":n:" where n is the line number)
1414
# Pipe this to another grep which looks for `:2:`, thus we get the file
15-
# Then, pipe this to `cut` which returns the first field delimited by ':'
16-
FILE=$( grep -rn "$KEY" $DIR | grep ":2:$KEY$" | cut -d ':' -f1 )
15+
# Then, pipe this to `cut` which returns the first field delimited by ':'
16+
FILE=$( grep -rn "$KEY" $DIR | grep ":2:$KEY$" | cut -d ':' -f1 )
1717
if [ ${#FILE} -eq 0 ] # Break when $FILE becomes empty, i.e we there is no file with the given $KEY
1818
then
1919
break

0 commit comments

Comments
 (0)