mirror of https://github.com/01-edu/public.git
3 changed files with 44 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/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 |
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
ls -p -tu | tr '\n' ',' | sed 's/.$//' |
@ -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…
Reference in new issue