From 48993bb4718d2335cac5d253fdd39e9ee0f440c0 Mon Sep 17 00:00:00 2001 From: nprimo Date: Mon, 16 Jan 2023 09:26:50 +0100 Subject: [PATCH] docs(remake): improve subject - run prettier to fix formatting - make example generic with `user` - improve clarity on exercise objective - remove created files after tests are run to allow consecutive tests executions without errors --- sh/tests/remake_test.sh | 3 +- subjects/devops/remake/README.md | 66 ++++++-------------------------- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/sh/tests/remake_test.sh b/sh/tests/remake_test.sh index e707468e..6e8126bb 100644 --- a/sh/tests/remake_test.sh +++ b/sh/tests/remake_test.sh @@ -9,10 +9,11 @@ challenge () { expected=$(bash solutions/remake.sh "$1"-expected) diff <(echo $submitted) <(echo $expected) diff <(ls -ltr $1) <(ls -ltr $1-expected) + rm -rf "$1" "$1-expected" else diff <(bash student/remake.sh "$@") <(bash solutions/remake.sh "$@") fi } -challenge a +challenge remake challenge diff --git a/subjects/devops/remake/README.md b/subjects/devops/remake/README.md index 30550e82..e2f76af5 100644 --- a/subjects/devops/remake/README.md +++ b/subjects/devops/remake/README.md @@ -2,72 +2,28 @@ ### Instructions -Create a file `remake.sh`, which will take one argument, the relative path of a directory, and will create new files and directories in it. +Create a file `remake.sh`, which will take one argument, the relative path of a directory, and will create new files and directories in it. The new files and directories created must have the same name, permission and modification dates as shown in the example below. If the number of given arguments is not one, your script should print `Error` and exit with the status code 1. -Below the expected behavior of your script: +Below the expected behavior of your script: ```console $ bash remake.sh given-path -$ ls -ltr given-path +$ ls -ltr given-path total 8 --r--r---w- 1 nprimo nprimo 0 Jan 1 00:01 ciao -drwxrwxrwx 2 nprimo nprimo 4096 Jan 2 00:01 mamma --r-------- 1 nprimo nprimo 0 Jan 3 00:01 guarda --rw-r---w- 1 nprimo nprimo 0 Jan 4 00:01 come -dr--r-x-w- 2 nprimo nprimo 4096 Jan 5 00:01 mi --r---w---x 1 nprimo nprimo 0 Jan 6 00:01 diverto -$ -``` - -### Hints - -- `mkdir ` command is used to create a new directory in the specified ``. For example: - -```console -$ ls -l -total 0 --rw-rw-r-- 1 nprimo nprimo 0 Jan 12 14:26 a --rw-rw-r-- 1 nprimo nprimo 0 Jan 12 14:26 b --rw-rw-r-- 1 nprimo nprimo 0 Jan 12 14:26 c -$ mkdir d -$ ls -l -total 4 --rw-rw-r-- 1 nprimo nprimo 0 Jan 12 14:26 a --rw-rw-r-- 1 nprimo nprimo 0 Jan 12 14:26 b --rw-rw-r-- 1 nprimo nprimo 0 Jan 12 14:26 c -drwxrwxr-x 2 nprimo nprimo 4096 Jan 12 14:26 d -$ -``` - -- `touch ` command is used to change the modification and/or access time of the specified `` to the current time. If the file does not exist yet, a new empty file is created at the specified ``. - -The flag `-t` allow to specify the time in the format `[[CC]YY]MMDDhhmm[.ss]` instead of the current time. - -- `chmod` The chmod, or change mode, command allows an administrator to set or modify a file’s permissions. Every UNIX/Linux file has an owner user and an owner group attached to it, and every file has permissions associated with it. The permissions are as follows: read, write, or execute. - -This is what the default permissions looks like when you create a file. - -```console -$ touch example.txt -$ ls -l example.txt --rw-rw-r-- 1 user user 348 dez 13 15:31 example.txt +-r--r---w- 1 user user 0 Jan 1 00:01 ciao +drwxrwxrwx 2 user user 4096 Jan 2 00:01 mamma +-r-------- 1 user user 0 Jan 3 00:01 guarda +-rw-r---w- 1 user user 0 Jan 4 00:01 come +dr--r-x-w- 2 user user 4096 Jan 5 00:01 mi +-r---w---x 1 user user 0 Jan 6 00:01 diverto $ ``` -This is what it looks like if you want to give permissions to read, write and execute to every group. +### Hints -```console -$ chmod 777 example.txt -$ ls -l example.txt --rwxrwxrwx 1 user user 348 dez 13 15:31 example.txt -$ -``` +- `touch -t ` allows to specify the modification time in the format `[[CC]YY]MMDDhhmm[.ss]` instead of the current time for the file at ``. > You have to use Man or Google to know more about commands flags, in order to solve this exercise! > Google and Man will be your friends! - -### References - -- [Chmod](https://www.linode.com/docs/guides/modify-file-permissions-with-chmod/#modify-file-permissions-with-chmod)