06-07-2020

This commit is contained in:
2020-07-06 15:20:17 +02:00
parent 05060c1e2e
commit b30fc7af77
8 changed files with 424 additions and 15 deletions

View File

@@ -283,41 +283,41 @@ test=$(find $dir -name "$name" -mmin -5 -maxdepth 1)
Si les chaines sont <u>*identiques*</u> [ STRING1 == STRING2 ]
```bash
if [ $1 = moo ]; then
if [ "$1" = "moo" ]; then
```
```bash
if [[ $1 == moo ]]; then
if [[ "$1" == "moo" ]]; then
```
Si les chaines sont <u>*différentes*</u> [ STRING1 != STRING2 ]
```bash
if [ $userinput != $password ]; then
if [ "$userinput" != "$password" ]; then
```
Si la chaine 1 *<u>contient la sous-chaine</u>* chaine 2
```bash
if [ $userinput == *$password* ]; then
if [ $userinput == $password* ]; then
if [ $userinput == *$password ]; then
if [ "$userinput" == *"$password"* ]; then
if [ "$userinput" == "$password"* ]; then
if [ "$userinput" == *"$password" ]; then
```
```bash
if [ $userinput =~ .*$password.* ]; then
if [ "$userinput" =~ .*$password.* ]; then
```
Si la chaine 1 <u>*est triée après*</u> la chaine 2 [ STRING1 > STRING2 ]
```bash
if [ $userinput” > “$password ]; then
if [ "$userinput" > "$password" ]; then
```
Si la chaine 1 <u>*est triée avant*</u> la chaine 2 [ STRING1 < STRING2 ]
```bash
if [ $userinput” < “$password ]; then
if [ "$userinput" < "$password" ]; then
```
Si la chaine <u>*NONEMPTYSTRING a une longueur > 0*</u> (contient 1 ou plusieurs caractères)
@@ -325,7 +325,7 @@ Si la chaine <u>*NONEMPTYSTRING a une longueur > 0*</u> (contient 1 ou plusieurs
```bash
if [ -n NONEMPTYSTRING ]; then
if [ -n $userinput ]; then
if [ -n "$userinput" ]; then
```
Si la chaine <u>*EMPTYSTRING est vide*</u> (NULL)
@@ -339,7 +339,7 @@ if [ -z $uninitializedvar ]; then
Si la chaine réussie la REGEX [[ STRING1 =~ REGEXPATTERN ]]
```bash
if [[ $email =~ “b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}b” ]]; then
if [[ "$email" =~ "b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}b" ]]; then
```
@@ -386,15 +386,15 @@ Exemples:
```bash
if [ $? -eq 0 ]; then # $? returns the exit status of the previous command
echo Previous command ran succesfully.
echo "Previous command ran succesfully."
fi
if [ $(ps -p $pid -o ni=) -ne $(nice) ]; then
echo Process $pid is running with a non-default nice value
echo "Process $pid is running with a non-default nice value"
fi
if [ $num -lt 0 ]; then
echo Negative numbers not allowed; exiting…
echo "Negative numbers not allowed; exiting…"
exit 1
fi
```

View File

@@ -32,6 +32,10 @@ grep -r "brew" ./docs/
grep -l -r "brew" ./docs/
./docs//Divers/plex.md
./docs//macos/node-js.md
root@localhost:/etc# grep -r 'max_allowed_packet' ./mysql/
./mysql/conf.d/mysqldump.cnf:max_allowed_packet = 16M
./mysql/mariadb.conf.d/50-server.cnf:max_allowed_packet = 16M
```