mirror of https://github.com/01-edu/public.git
docs(bin-status): fix the usage of bin status
format readmes of other exercises
This commit is contained in:
parent
26bf95547d
commit
768f97e4a4
|
@ -7,9 +7,9 @@ Create the script `bin-status.sh` that will return the exit status of last comma
|
|||
- Expected output:
|
||||
|
||||
```console
|
||||
$ true ; ./bin-status.sh
|
||||
$ true ; source ./bin-status.sh
|
||||
0
|
||||
$ false ; ./bin-status.sh
|
||||
$ false ; source ./bin-status.sh
|
||||
1
|
||||
$
|
||||
```
|
||||
|
@ -27,5 +27,7 @@ $ random-binary ; echo $?
|
|||
$
|
||||
```
|
||||
|
||||
The `source` command is used in Unix-like operating systems to execute commands from a specified file in the current shell environment. When the `source` command is used, the specified file is read by the shell and executed in the same environment as the caller, without creating a new subshell.
|
||||
|
||||
> 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!
|
|
@ -8,6 +8,7 @@ In this exercise you will make a script `calculator.sh` that will take 3 argumen
|
|||
- The second argument will be the operator.
|
||||
|
||||
Each operator should have its own function named as follow:
|
||||
|
||||
- `+`: `do_add()`.
|
||||
- `-`: `do_sub()`.
|
||||
- `*`: `do_mult()`.
|
||||
|
@ -36,6 +37,7 @@ $
|
|||
### Error handling
|
||||
|
||||
All errors will print a specific message on **stderr** (ending with a newline) and returns a specific non-zero value:
|
||||
|
||||
- Wrong number of arguments: `"Error: expect 3 arguments"`, returns `1`.
|
||||
- Division by 0: `"Error: division by 0"`, exit with `2`.
|
||||
- Invalid operator: `"Error: invalid operator"`, exit with `3`.
|
||||
|
@ -46,6 +48,7 @@ All errors will print a specific message on **stderr** (ending with a newline) a
|
|||
### Hints
|
||||
|
||||
- `case` statement example:
|
||||
|
||||
```sh
|
||||
# Check the first argument given to a script
|
||||
case $1 in
|
||||
|
@ -76,6 +79,7 @@ esac
|
|||
|
||||
- Example of a function taking two arguments and returning a value by printing it.
|
||||
The behavior of this function is the same than the one expected for the operators functions you will create:
|
||||
|
||||
```sh
|
||||
print_full_name () {
|
||||
name=$1
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
In this exercise you will make a script `check-user.sh` that will take 2 arguments and return information about the selected user, always ended by a new line.
|
||||
|
||||
The first argument will be a flag defining the behavior of the script:
|
||||
|
||||
- `-e`: check if the user exists, returns `yes` or `no` appropriately.
|
||||
- `-i`: returns information about the user.
|
||||
|
||||
|
@ -30,10 +31,12 @@ $
|
|||
### Error handling
|
||||
|
||||
All errors will print a specific message on **stderr** (ending with a newline) and returns a specific non-zero value:
|
||||
|
||||
- Wrong number of arguments: `"Error: expect 2 arguments"`, exit with `1`.
|
||||
- First argument different from `-e` or `-i`: `"Error: unknown flag"`, exit with `1`.
|
||||
|
||||
### Hints
|
||||
|
||||
- `getent` is a command to get entries from a database. `passwd` is the database where information about users is stored.
|
||||
- `getent passwd` will give you the list of all users.
|
||||
- `getent passwd <username>` will give you information about a specific user.
|
||||
|
@ -42,4 +45,5 @@ All errors will print a specific message on **stderr** (ending with a newline) a
|
|||
> `man getent` will provide extensive documentation about this command.
|
||||
|
||||
### Resources
|
||||
|
||||
> [List Linux users](https://linuxize.com/post/how-to-list-users-in-linux/)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
Create the script `custom-ls.sh` which will create an alias `custom-ls`.
|
||||
|
||||
The alias `custom-ls`:
|
||||
|
||||
- shows the file details in long list format.
|
||||
- does not list group information.
|
||||
- does not ignore entries starting with `.`.
|
||||
|
@ -45,17 +46,22 @@ $
|
|||
To create and add aliases permanently to your bash shell on Linux and Unix-like systems:
|
||||
|
||||
1- Edit the `~/.bashrc`:
|
||||
|
||||
```console
|
||||
vi ~/.bashrc
|
||||
# or #
|
||||
nano ~/.bashrc
|
||||
```
|
||||
|
||||
2- Append your bash alias, For example append:
|
||||
|
||||
```console
|
||||
alias testcmd="echo 01school"
|
||||
```
|
||||
|
||||
3- Save and close the file.
|
||||
4- Activate alias
|
||||
|
||||
```console
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
|
|
@ -9,7 +9,7 @@ If it exists and it is executable you must print "File is executable" if it is n
|
|||
|
||||
```console
|
||||
$ ls -l
|
||||
-rw-rw-r-- 1 miguel miguel 19 dez 28 14:19 docs
|
||||
-rw-rw-r-- 1 user user 19 dez 28 14:19 docs
|
||||
-rwxrwxr-x 1 user user 95 dez 29 15:48 example.sh
|
||||
$ ./hard-conditions.sh path/to/example.sh
|
||||
File is executable
|
||||
|
|
Loading…
Reference in New Issue