From cabe2e248f606c56f8fbceaf176475a32f371b91 Mon Sep 17 00:00:00 2001 From: Zouhair AMAZZAL Date: Sat, 3 Dec 2022 02:16:57 +0100 Subject: [PATCH] feat(find-files): add subject, test and solution for new a exercise --- sh/tests/find-files/folder1/ab | 0 sh/tests/find-files/folder1/ac | 0 sh/tests/find-files/folder1/az | 0 sh/tests/find-files/folder1/bz | 0 sh/tests/find-files/folder1/cz | 0 sh/tests/find-files/folder1/za! | 0 sh/tests/find-files/folder2/aa/aa | 0 sh/tests/find-files/folder2/aa/az | 0 sh/tests/find-files/folder2/aa/ba/ab | 0 sh/tests/find-files/folder2/aa/ba/bz | 0 sh/tests/find-files/folder2/ab | 0 sh/tests/find-files/folder2/ac | 0 sh/tests/find-files/folder2/alphabet | 0 sh/tests/find-files/folder2/az | 0 sh/tests/find-files/folder2/ba/aa/alphabetz! | 0 sh/tests/find-files/folder2/ba/aa/cz | 0 sh/tests/find-files/folder2/ba/aa/za! | 0 sh/tests/find-files/folder2/ba/ac | 0 sh/tests/find-files/folder2/ba/alphabetz | 0 sh/tests/find-files/folder2/bz | 0 sh/tests/find-files/folder2/cz | 0 sh/tests/find-files/folder2/za! | 0 sh/tests/find-files_test.sh | 18 ++++++++ sh/tests/solutions/find-files.sh | 3 ++ subjects/find-files/README.md | 47 ++++++++++++++++++++ 25 files changed, 68 insertions(+) create mode 100644 sh/tests/find-files/folder1/ab create mode 100644 sh/tests/find-files/folder1/ac create mode 100644 sh/tests/find-files/folder1/az create mode 100644 sh/tests/find-files/folder1/bz create mode 100644 sh/tests/find-files/folder1/cz create mode 100644 sh/tests/find-files/folder1/za! create mode 100644 sh/tests/find-files/folder2/aa/aa create mode 100644 sh/tests/find-files/folder2/aa/az create mode 100644 sh/tests/find-files/folder2/aa/ba/ab create mode 100644 sh/tests/find-files/folder2/aa/ba/bz create mode 100644 sh/tests/find-files/folder2/ab create mode 100644 sh/tests/find-files/folder2/ac create mode 100644 sh/tests/find-files/folder2/alphabet create mode 100644 sh/tests/find-files/folder2/az create mode 100644 sh/tests/find-files/folder2/ba/aa/alphabetz! create mode 100644 sh/tests/find-files/folder2/ba/aa/cz create mode 100644 sh/tests/find-files/folder2/ba/aa/za! create mode 100644 sh/tests/find-files/folder2/ba/ac create mode 100644 sh/tests/find-files/folder2/ba/alphabetz create mode 100644 sh/tests/find-files/folder2/bz create mode 100644 sh/tests/find-files/folder2/cz create mode 100644 sh/tests/find-files/folder2/za! create mode 100755 sh/tests/find-files_test.sh create mode 100755 sh/tests/solutions/find-files.sh create mode 100644 subjects/find-files/README.md diff --git a/sh/tests/find-files/folder1/ab b/sh/tests/find-files/folder1/ab new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder1/ac b/sh/tests/find-files/folder1/ac new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder1/az b/sh/tests/find-files/folder1/az new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder1/bz b/sh/tests/find-files/folder1/bz new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder1/cz b/sh/tests/find-files/folder1/cz new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder1/za! b/sh/tests/find-files/folder1/za! new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/aa/aa b/sh/tests/find-files/folder2/aa/aa new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/aa/az b/sh/tests/find-files/folder2/aa/az new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/aa/ba/ab b/sh/tests/find-files/folder2/aa/ba/ab new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/aa/ba/bz b/sh/tests/find-files/folder2/aa/ba/bz new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/ab b/sh/tests/find-files/folder2/ab new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/ac b/sh/tests/find-files/folder2/ac new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/alphabet b/sh/tests/find-files/folder2/alphabet new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/az b/sh/tests/find-files/folder2/az new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/ba/aa/alphabetz! b/sh/tests/find-files/folder2/ba/aa/alphabetz! new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/ba/aa/cz b/sh/tests/find-files/folder2/ba/aa/cz new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/ba/aa/za! b/sh/tests/find-files/folder2/ba/aa/za! new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/ba/ac b/sh/tests/find-files/folder2/ba/ac new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/ba/alphabetz b/sh/tests/find-files/folder2/ba/alphabetz new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/bz b/sh/tests/find-files/folder2/bz new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/cz b/sh/tests/find-files/folder2/cz new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files/folder2/za! b/sh/tests/find-files/folder2/za! new file mode 100644 index 000000000..e69de29bb diff --git a/sh/tests/find-files_test.sh b/sh/tests/find-files_test.sh new file mode 100755 index 000000000..ec25caaa4 --- /dev/null +++ b/sh/tests/find-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/find-files.sh) + expected=$(cd "$1" && bash "$script_dirS"/solutions/find-files.sh) + + diff <(echo "$submitted") <(echo "$expected") +} + +challenge find-files/folder1 +challenge find-files/folder2 diff --git a/sh/tests/solutions/find-files.sh b/sh/tests/solutions/find-files.sh new file mode 100755 index 000000000..9e11e2d2e --- /dev/null +++ b/sh/tests/solutions/find-files.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find . \( -name 'a*' -or -type f -name '*z' \) \ No newline at end of file diff --git a/subjects/find-files/README.md b/subjects/find-files/README.md new file mode 100644 index 000000000..aa7cd9283 --- /dev/null +++ b/subjects/find-files/README.md @@ -0,0 +1,47 @@ +## find-files + +### Instructions + +"start finding ..." + +Create a file `find-files.sh`, which will look for and show, in the current directory and its sub-folders: + +everything that starts with an `a` or, +all the files ending with a `z` or, + + +- You can use this for testing: https://assets.01-edu.org/devops-branch/find-files-example.zip + +- What to use : `find` + +- The output should be exactly like the example bellow but with the expected name + +```console +$pwd +<..>/find-files-example +$./find-files.sh +./folder2/zzzz +./folder3/asd +./folder3/sub-folder4/abc +./folder3/sub-folder4/a_correct +./folder3/sub-folder4/aefg +./folder3/asd 2 +./folder3/ahmed +./folder1/aolder_lol +$ +``` + +### Hints + +`find` command is used to search and locate the list of files and directories based on conditions you specify for files that match the arguments: + +```console +$find ~/ + +$find ~/ \( -type f \) + +$ +``` + +> You have to use Man or Google to know more about commands flags, in order to solve this exercice! +> Google and Man will be your friends! \ No newline at end of file