Browse Source

feat(master-the-ls): add subject, test and solution for the exercise master-the-ls

DEV-4017-prototypes-exercise-1-animals
miguel 2 years ago committed by MSilva95
parent
commit
9dbebae756
  1. 18
      sh/tests/master-the-ls_test.sh
  2. 3
      sh/tests/solutions/master-the-ls
  3. 23
      subjects/master-the-ls/README.md

18
sh/tests/master-the-ls_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/master-the-ls)
expected=$(cd "$1" && bash "$script_dirS"/solutions/master-the-ls)
diff <(echo "$submitted") <(echo "$expected")
}
challenge cl-camp1/folder1
challenge cl-camp1/folder2

3
sh/tests/solutions/master-the-ls

@ -0,0 +1,3 @@
#!/usr/bin/env bash
ls -p -tu | tr '\n' ',' | sed 's/.$//'

23
subjects/master-the-ls/README.md

@ -0,0 +1,23 @@
## Master the ls
### Instructions
Put in a file `master-the-ls`, the command line that will:
- list the files and directories of the current directory.
- Ignore the hidden files, the "." and the "..".
- Separates the results with commas.
- Order them by ascending order of access time (the newest first).
- Have the directories ends with a `/`.
### Hint
Here are some Commands that can help you:
- `tr`. Translate characters: run replacements based on single characters and character sets.For more information: https://www.gnu.org/software/coreutils/tr.
- Replace all occurrences of a character in a file, and print the result:
`tr {{find_character}} {{replace_character}} < {{filename}}`
- `ls`. List directory contents. For more information: https://www.gnu.org/software/coreutils/ls.
- `sed`. Edit text in a scriptable manner. You can see also: awk. For more information: https://www.gnu.org/software/sed/manual/sed.html.
Loading…
Cancel
Save