We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e56876 commit 32fa3e3Copy full SHA for 32fa3e3
exercises/shell/solutions/directories_comparison.md
@@ -0,0 +1,30 @@
1
+## Directories Comparison
2
+
3
+### Objectives
4
5
+1. You are given two directories as arguments and the output should be any difference between the two directories
6
7
+### Solution
8
9
+Suppose the name of the bash script is ```dirdiff.sh```
10
11
+```
12
+#!/bin/bash
13
14
+if test $# -ne 2
15
+then
16
+ echo -e "USAGE: ./dirdiff.sh directory1 directory2"
17
+ exit 1
18
+fi
19
20
+# check for the checksums.
21
+# If both the checksums same, then both directories are same
22
+if test `ls -1 $1 | sort | md5sum | awk -F " " '{print $1}'` == `ls -1 $2 | sort | md5sum | awk -F " " '{print $1}'`
23
24
+ echo -e "No difference between the 2 directories"
25
+ exit 0
26
27
28
+diff -q $1 $2
29
30
0 commit comments