Browse Source

feat(count-files): add subject, test and solution for the exercise count-files

pull/1658/head
miguel 2 years ago committed by MSilva95
parent
commit
7849dc44fb
  1. 18
      sh/tests/count-files_test.sh
  2. 3
      sh/tests/solutions/count-files.sh
  3. 22
      subjects/count-files/README.md

18
sh/tests/count-files_test.sh

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS='
'
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(cd "$1" && bash "$script_dirS"/student/count-files.sh)
expected=$(cd "$1" && bash "$script_dirS"/solutions/count-files.sh)
diff <(echo "$submitted") <(echo "$expected")
}
challenge cl-camp5/folder1
challenge cl-camp5/folder2

3
sh/tests/solutions/count-files.sh

@ -0,0 +1,3 @@
#!/usr/bin/env bash
find . -type d,f | wc -l

22
subjects/count-files/README.md

@ -0,0 +1,22 @@
## Count files
### Instructions
Create a file `count-files.sh`, which will print the number **(and only the number)** of regular files and folders contained in the current directory and its sub-folders (the current directory must be included in the count):
### Usage
```console
$ ./count-files.sh | cat -e
12$
$
```
**Tips:**
Here are some Commands that can help you:
- `find`. Find files or directories under the given directory tree, recursively. [For more information](https://manned.org/find).
- `wc`. Count lines, words, and bytes. [For more information](https://www.gnu.org/software/coreutils/wc).
Use the man to get more info on the commands `find` and `wc`.
Loading…
Cancel
Save