Browse Source

feat(find-files-extention): add subject, test and solution for new a exercise

pull/1637/head
Zouhair AMAZZAL 2 years ago committed by Zouhair AMAZZAL
parent
commit
1f284b5c43
  1. 0
      sh/tests/find-files-extension/folder1/file1.txt
  2. 0
      sh/tests/find-files-extension/folder1/file2.txt
  3. 0
      sh/tests/find-files-extension/folder1/file3.txt
  4. 0
      sh/tests/find-files-extension/folder1/test4.sh
  5. 0
      sh/tests/find-files-extension/folder2/fileInsideAfolder4.txt
  6. 0
      sh/tests/find-files-extension/folder2/test.sh
  7. 0
      sh/tests/find-files-extension/folder2/testtxt/fileInsideAfolder5.txt
  8. 0
      sh/tests/find-files-extension/folder2/testtxt/test/fileInsideAfolder6.txt
  9. 0
      sh/tests/find-files-extension/folder2/testtxt/test/lol.sh
  10. 18
      sh/tests/find-files-extension_test.sh
  11. 3
      sh/tests/solutions/find-files-extension.sh
  12. 59
      subjects/find-files-extension/README.md

0
sh/tests/find-files-extension/folder1/file1.txt

0
sh/tests/find-files-extension/folder1/file2.txt

0
sh/tests/find-files-extension/folder1/file3.txt

0
sh/tests/find-files-extension/folder1/test4.sh

0
sh/tests/find-files-extension/folder2/fileInsideAfolder4.txt

0
sh/tests/find-files-extension/folder2/test.sh

0
sh/tests/find-files-extension/folder2/testtxt/fileInsideAfolder5.txt

0
sh/tests/find-files-extension/folder2/testtxt/test/fileInsideAfolder6.txt

0
sh/tests/find-files-extension/folder2/testtxt/test/lol.sh

18
sh/tests/find-files-extension_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-extension.sh)
expected=$(cd "$1" && bash "$script_dirS"/solutions/find-files-extension.sh)
diff <(echo "$submitted") <(echo "$expected")
}
challenge find-files-extension/folder1
challenge find-files-extension/folder2

3
sh/tests/solutions/find-files-extension.sh

@ -0,0 +1,3 @@
#!/bin/bash
find . -iregex '.*\.\(txt\)' -exec basename {} \; | cut -d "." -f 1

59
subjects/find-files-extension/README.md

@ -0,0 +1,59 @@
## find-files-extension
### Instructions
Create a file `find-files-extension.sh`, which will look, from the current directory and its sub-folders for:
all the files with `.txt` extension.
That command will only show the name of the files without the extension `.txt`.
- You can use this for testing: https://assets.01-edu.org/devops-branch/find-files-extension-example.zip
- What to use : `find`
- The output should be exactly like the example bellow but with the expected name
```console
$pwd
<..>/find-files-extension-example
$./find-files-extension.sh | cat -e
qwep$
pq1$
zzzz$
ziko$
wei$
ek$
$
```
### 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:
You can use REGEX in `find` command.
```console
$find ~/ -iregex '<REGEX>'
<all files and folders in the user home that respect the specified regex>
$
```
REGEX for txt files: `.*\.\(txt\)`
`cut` command is a command-line utility that allows you to cut out sections of a specified file or piped data and print the result:
```console
$cat cut-example.txt
abc-lol
testtest-abcx
qwerty-azerty-x
$cat cut-example.txt | cut -d "-" -f 1 # cut the lines with "-" as delimiter and print the first part.
abc
testtest
qwerty
$
```
May you will need to use `pipe (|)` and `&&`.
> 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!
Loading…
Cancel
Save