Added a shorter solution for the directory diff exercise (#344)
Signed-off-by: Fabio Kruger <10956489+krufab@users.noreply.github.com>
This commit is contained in:
parent
47c39f6e9a
commit
c664d2e7e2
@ -14,7 +14,7 @@
|
|||||||
|Sum|Functions|[Exercise](sum.md)|[Solution](solutions/sum.md) | Basic
|
|Sum|Functions|[Exercise](sum.md)|[Solution](solutions/sum.md) | Basic
|
||||||
|Number of Arguments|Case Statement|[Exercise](num_of_args.md)|[Solution](solutions/num_of_args.md) | Basic
|
|Number of Arguments|Case Statement|[Exercise](num_of_args.md)|[Solution](solutions/num_of_args.md) | Basic
|
||||||
|Empty Files|Misc|[Exercise](empty_files.md)|[Solution](solutions/empty_files.md) | Basic
|
|Empty Files|Misc|[Exercise](empty_files.md)|[Solution](solutions/empty_files.md) | Basic
|
||||||
|Directories Comparison|Misc|[Exercise](directories_comparison.md)| :( | Basic
|
|Directories Comparison|Misc|[Exercise](directories_comparison.md)|[Solution](solutions/directories_comparison.md) | Basic
|
||||||
|It's alive!|Misc|[Exercise](host_status.md)|[Solution](solutions/host_status.md) | Intermediate
|
|It's alive!|Misc|[Exercise](host_status.md)|[Solution](solutions/host_status.md) | Intermediate
|
||||||
|
|
||||||
## Shell Scripting - Self Assessment
|
## Shell Scripting - Self Assessment
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
1. You are given two directories as arguments and the output should be any difference between the two directories
|
1. You are given two directories as arguments and the output should be any difference between the two directories
|
||||||
|
|
||||||
### Solution
|
### Solution 1
|
||||||
|
|
||||||
Suppose the name of the bash script is ```dirdiff.sh```
|
Suppose the name of the bash script is ```dirdiff.sh```
|
||||||
|
|
||||||
@ -26,5 +26,12 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
diff -q $1 $2
|
diff -q $1 $2
|
||||||
|
```
|
||||||
|
|
||||||
|
### Solution 2
|
||||||
|
|
||||||
|
With gnu find, you can use diff to compare directories recursively.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
diff --recursive directory1 directory2
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user