mirror of https://github.com/01-edu/public.git
3 changed files with 43 additions and 0 deletions
@ -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 |
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
find . -type d,f | wc -l |
@ -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…
Reference in new issue