Skip to content

Commit 32fa3e3

Browse files
Prajwalmithuneshack94
authored andcommitted
added solution for directories_comparision.md (bregman-arie#249)
* added solution to directories_comparision.md * updated the previous shell code
1 parent 5e56876 commit 32fa3e3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
then
24+
echo -e "No difference between the 2 directories"
25+
exit 0
26+
fi
27+
28+
diff -q $1 $2
29+
30+
```

0 commit comments

Comments
 (0)