mirror of https://github.com/01-edu/public.git
docs(scripting-piscine): improving readmes
This commit is contained in:
parent
89cce5082d
commit
b2cfe769b4
|
@ -54,7 +54,7 @@ All errors will print a specific message on **stderr** (ending with a newline) a
|
|||
|
||||
- Wrong number of arguments: `"Error: expect 1 argument only!"`, exit with `1`.
|
||||
|
||||
- If the student grade is not a number or is greater than 100: `Error: The grade "grade" is not a valid input. Only numerical grades between 0 and 100 are accepted.`, exit with `1`.
|
||||
- If the student grade is not a number or is greater than 100: `Error: The grade <grade> is not a valid input. Only numerical grades between 0 and 100 are accepted.`, exit with `1`.
|
||||
|
||||
```console
|
||||
$ ./grades.sh 2
|
||||
|
|
|
@ -9,17 +9,17 @@ Right now the folder looks like this:
|
|||
```console
|
||||
$ ls -l hard-perm
|
||||
total 12
|
||||
drwxrwxr-x 2 user user 4096 dez 13 18:10 0
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 1
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 2
|
||||
drwxrwxr-x 2 user user 4096 dez 13 18:10 3
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 4
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 5
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 6
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 7
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 8
|
||||
-rw-rw-r-- 1 user user 0 dez 13 18:11 9
|
||||
drwxrwxr-x 2 user user 4096 dez 13 18:10 A
|
||||
drwxrwxr-x 2 user user 4096 dec 13 18:10 0
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 1
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 2
|
||||
drwxrwxr-x 2 user user 4096 dec 13 18:10 3
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 4
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 5
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 6
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 7
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 8
|
||||
-rw-rw-r-- 1 user user 0 dec 13 18:11 9
|
||||
drwxrwxr-x 2 user user 4096 dec 13 18:10 A
|
||||
|
||||
```
|
||||
|
||||
|
@ -28,17 +28,17 @@ Expected output:
|
|||
```console
|
||||
$ ls -l hard-perm
|
||||
total 12
|
||||
dr-------x 2 user user 4096 dez 13 17:50 0
|
||||
-r------w- 1 user user 0 dez 13 17:51 1
|
||||
-rw----r-- 1 user user 0 dez 13 17:51 2
|
||||
drwxrwxrwx 2 user user 4096 dez 13 17:51 3
|
||||
-r-x--x--- 1 user user 0 dez 13 17:51 4
|
||||
-r--rw---- 1 user user 0 dez 13 17:51 5
|
||||
-r--rw---- 1 user user 0 dez 13 17:51 6
|
||||
-r-x--x--- 1 user user 0 dez 13 17:51 7
|
||||
-rw----r-- 1 user user 0 dez 13 17:51 8
|
||||
-r------w- 1 user user 0 dez 13 17:51 9
|
||||
dr-------x 2 user user 4096 dez 13 17:50 A
|
||||
dr-------x 2 user user 4096 dec 13 17:50 0
|
||||
-r------w- 1 user user 0 dec 13 17:51 1
|
||||
-rw----r-- 1 user user 0 dec 13 17:51 2
|
||||
drwxrwxrwx 2 user user 4096 dec 13 17:51 3
|
||||
-r-x--x--- 1 user user 0 dec 13 17:51 4
|
||||
-r--rw---- 1 user user 0 dec 13 17:51 5
|
||||
-r--rw---- 1 user user 0 dec 13 17:51 6
|
||||
-r-x--x--- 1 user user 0 dec 13 17:51 7
|
||||
-rw----r-- 1 user user 0 dec 13 17:51 8
|
||||
-r------w- 1 user user 0 dec 13 17:51 9
|
||||
dr-------x 2 user user 4096 dec 13 17:50 A
|
||||
```
|
||||
|
||||
### Hints
|
||||
|
@ -50,7 +50,7 @@ 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
|
||||
-rw-rw-r-- 1 user user 348 dec 13 15:31 example.txt
|
||||
$
|
||||
```
|
||||
|
||||
|
@ -59,7 +59,7 @@ This is what it looks like if you want to give permissions to read, write and ex
|
|||
```console
|
||||
$ chmod 777 example.txt
|
||||
$ ls -l example.txt
|
||||
-rwxrwxrwx 1 user user 348 dez 13 15:31 example.txt
|
||||
-rwxrwxrwx 1 user user 348 dec 13 15:31 example.txt
|
||||
$
|
||||
```
|
||||
|
||||
|
@ -68,7 +68,7 @@ You can also achieve the same result using symbolic notation.
|
|||
```console
|
||||
$ chmod a+rwx example.txt
|
||||
$ ls -l example.txt
|
||||
-rwxrwxrwx 1 user user 348 dez 13 15:31 example.txt
|
||||
-rwxrwxrwx 1 user user 348 dec 13 15:31 example.txt
|
||||
$
|
||||
```
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
### Instructions
|
||||
|
||||
Create the script `head-and-tail.sh` wich will show the first and last lines of the file `HeadTail.txt`
|
||||
Create the script `head-and-tail.sh` which will show the first and last lines of the file `HeadTail.txt`
|
||||
|
||||
- Where to look : https://assets.01-edu.org/devops-branch/HeadTail.txt
|
||||
|
||||
|
@ -11,7 +11,7 @@ Create the script `head-and-tail.sh` wich will show the first and last lines of
|
|||
- The output should be exactly like the example bellow but with the expected name
|
||||
|
||||
```console
|
||||
$./head-and-tail.sh | cat -e
|
||||
$ ./head-and-tail.sh | cat -e
|
||||
Hello My username is: <...>,$
|
||||
so my passwd is: <...>$
|
||||
$
|
||||
|
@ -22,7 +22,7 @@ $
|
|||
With `curl` you can get the content of the file from the url:
|
||||
|
||||
```console
|
||||
$curl https://assets.01-edu.org/devops-branch/HeadTail.txt
|
||||
$ curl https://assets.01-edu.org/devops-branch/HeadTail.txt
|
||||
<...>
|
||||
$
|
||||
```
|
||||
|
@ -40,16 +40,14 @@ $
|
|||
`tail` print the last N number of data of the given input. By default, it prints the last 10 lines of the specified files:
|
||||
|
||||
```console
|
||||
$tail file
|
||||
$ tail file
|
||||
<last 10 lines>
|
||||
$tail -1 file
|
||||
$ tail -1 file
|
||||
<last 1 line>
|
||||
$
|
||||
```
|
||||
|
||||
You may need to use pipes `(|)` and the logical operator `&&`.
|
||||
|
||||
|
||||
|
||||
> 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!
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
Create a script `in-back-ground.sh` which will execute a job in the background that will do the following:
|
||||
|
||||
- Run the command `cat` on the file "facts" which will read the contents of the file and print it to `stdout`.
|
||||
- Run the command `cat` on the file [facts](../../../sh/tests/left/facts) which will read the contents of the file and print it to `stdout`.
|
||||
- The output of the cat command will be piped to the `grep` command, which will search for the string `"moon"` in the file.
|
||||
- If the `grep` command succeeds (if it finds the string "moon"), you will print `"The moon fact was found!"` to the `output.txt` file. If it fails the file `output.txt` is not created.
|
||||
- If the command finds the string "moon", it will print the matching line to the `stdout`.
|
||||
- If the `grep` command succeeds (if it finds the string "moon"):
|
||||
- You will print `"The moon fact was found!"` to the `output.txt` file. If it fails the file `output.txt` is not created.
|
||||
- You will should also print the line which contains the string to the `stdout`.
|
||||
- Redirect the `stdout` to a new file `output.txt`.
|
||||
|
||||
You must do all these steps running only one job and using the command `nohup`!
|
||||
|
|
|
@ -6,12 +6,13 @@ In this exercise you are going to create a guessing game.
|
|||
Create the script `joker-num.sh` which will receive the number to guess as argument. The number should be between 1 and 100 (inclusive). The player will then have 5 tries to guess the number.
|
||||
To achieve this you will have to use a `for` loop.
|
||||
|
||||
When guessing a valid number the output will be:
|
||||
When you're trying to guess the secret number with a valid input, your program must output some tips as follow:
|
||||
|
||||
- Number bigger than the secret one: `Go down`.
|
||||
- Number smaller than the secret one: `Go up`.
|
||||
- Number equal than the secret one: `Congratulations, you found the number!`.
|
||||
- Ran out of tries: `You lost, the number was <number>`.
|
||||
- First you will need to prompt a message so that the player knows what he must do: `"Enter your guess (<tries_left> tries left)`.
|
||||
- If the number is bigger than the secret one: `Go down`.
|
||||
- If the number si smaller than the secret one: `Go up`.
|
||||
- If the number is the correct one: `Congratulations, you found the number in <number_of_tries> moves!`.
|
||||
- If you ran out of tries: `You lost, the number was <number>`.
|
||||
|
||||
### Usage
|
||||
|
||||
|
@ -35,8 +36,8 @@ $
|
|||
|
||||
### Error handling
|
||||
|
||||
- Wrong number of arguments or number not between `1` and `100`: The program will print `Error: wrong argument` and return `1`.
|
||||
- The player writing something that is not a valid number as an answer: The program will ask again to enter a guess and the number of tries won't be decremented.
|
||||
- If the player enters the wrong number of arguments or the number is not between `1` and `100`, the program will print `Error: wrong argument` and exit with `1`.
|
||||
- If the player is writing something that is not a valid number as an answer, the program will ask again to enter a new a guess and the number of tries won't be decremented.
|
||||
|
||||
Here an example for the last scenario:
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ $
|
|||
|
||||
### Hints
|
||||
|
||||
- Asynchronous behavior, in the context of server-side JavaScript, refers to the ability of running code in a non-blockingly way, meaning for instance that the server can handle multiple requests simultaneously without waiting for a long-running task to complete, avoiding blocking the server responsiveness. It is essential to achieve scalable and functional back-end Node applications.
|
||||
- Asynchronous behavior, in the context of server-side JavaScript, refers to the ability of running code in a non-blocking way, meaning for instance that the server can handle multiple requests simultaneously without waiting for a long-running task to complete, avoiding blocking the server responsiveness. It is essential to achieve scalable and functional back-end Node applications.
|
||||
|
||||
- A `Promise` is a special JS object that represent the result (succes or failure) of an asynchronous operation. This special object is usually used to "wrap" asynchronous operations.
|
||||
- A `Promise` is a special JS object that represent the result (success or failure) of an asynchronous operation. This special object is usually used to "wrap" asynchronous operations.
|
||||
`Promise`s can have three different states: _pending_ - the asynchronous operation has not finished yet, _fulfilled_/_resolved_ - the asynchronous operation has finished successfully - or _rejected_ - the asynchronous operation has finished, but something went wrong. When defined from scratch, it is possible to define a `resolve` and `reject` callback function for a new `Promise` that will define the results of the success or failure of asynchronous operation happening inside the `Promise`.
|
||||
|
||||
- It is possible to wait for an asynchronous function with the keyword `await`. Alternatively, it can be clearer to use the method `.then`. Below an example of how to handle promises and, more generally, asynchronous operations.
|
||||
|
|
|
@ -11,7 +11,7 @@ The script will also have to find and take into account hidden files.
|
|||
Here is an example of how to use the script:
|
||||
|
||||
```console
|
||||
$ tree -ha
|
||||
$ tree -ha
|
||||
[4.0K] .
|
||||
├── [4.0K] d1
|
||||
│ ├── [4.0K] d1-1
|
||||
|
|
|
@ -7,7 +7,7 @@ Create a file `left.sh` that will pass the content of a file `facts` to a comman
|
|||
### Usage
|
||||
|
||||
```console
|
||||
$./left.sh
|
||||
$ ./left.sh
|
||||
21
|
||||
```
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ If the number of given arguments is not one or if the directory given as argumen
|
|||
Below the expected behavior of your script:
|
||||
|
||||
```console
|
||||
$ bash remake.sh given-path
|
||||
$ ls -ltr given-path
|
||||
$ bash remake.sh given-path
|
||||
$ ls -ltr given-path
|
||||
total 8
|
||||
-r--r---w- 1 user user 0 Jan 1 00:01 ciao
|
||||
drwxrwxrwx 2 user user 4096 Jan 2 00:01 mamma
|
||||
|
|
Loading…
Reference in New Issue