Browse Source

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
DEV-4397-piscine-ai-missing-file-for-ex-7-of-nlp
nprimo 1 year ago committed by Niccolò Primo
parent
commit
48993bb471
  1. 3
      sh/tests/remake_test.sh
  2. 66
      subjects/devops/remake/README.md

3
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

66
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 <relative-path>` command is used to create a new directory in the specified `<relative-path>`. 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 <file-path>` command is used to change the modification and/or access time of the specified `<file-path>` to the current time. If the file does not exist yet, a new empty file is created at the specified `<file-path>`.
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 <file-path>` allows to specify the modification time in the format `[[CC]YY]MMDDhhmm[.ss]` instead of the current time for the file at `<file-path>`.
> 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)

Loading…
Cancel
Save