14-11-2023
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
# ack
|
||||
|
||||
Remplaçant de *grep*
|
||||
|
||||
https://beyondgrep.com
|
||||
|
||||
|
||||
|
||||
Installation:
|
||||
|
||||
```bash
|
||||
$ brew install ack
|
||||
```
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
- [exa](exa.md)
|
||||
- [fd](fd.md)
|
||||
- [fzf](fzf.md)
|
||||
- ripgrep
|
||||
- zoxide
|
||||
- [ripgrep](ripgrep.md)
|
||||
- [zoxide](zoxide.md)
|
||||
|
||||
|
||||
|
||||
@@ -15,14 +15,20 @@
|
||||
|
||||
### bat
|
||||
|
||||
alternative à *cat*
|
||||
|
||||
https://github.com/sharkdp/bat
|
||||
|
||||
### exa
|
||||
|
||||
alternative à *ls*
|
||||
|
||||
https://the.exa.website
|
||||
|
||||
### fd
|
||||
|
||||
alternative à *find*
|
||||
|
||||
https://github.com/sharkdp/fd
|
||||
|
||||
### fzf
|
||||
@@ -31,175 +37,13 @@ https://github.com/junegunn/fzf
|
||||
|
||||
### ripgrep (rg)
|
||||
|
||||
alternative à *grep*
|
||||
|
||||
https://github.com/BurntSushi/ripgrep
|
||||
|
||||
##### Installation:
|
||||
|
||||
```bash
|
||||
$ brew install ripgrep
|
||||
```
|
||||
|
||||
##### Utilisation:
|
||||
|
||||
```bash
|
||||
$ rg PATH ~/.zshrc
|
||||
```
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
# regex ('core' plus 1 ou plusiers lettres)
|
||||
$ rg 'core\w+' ~/.zshrc
|
||||
22:PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH
|
||||
25:coreutils=false
|
||||
|
||||
# regex ('core' plus 0 ou plusiers lettres)
|
||||
$ rg 'core\w*' ~/.zshrc
|
||||
22:PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH
|
||||
25:coreutils=false
|
||||
|
||||
# string
|
||||
$ rg -F 'eval "$(' ~/.zshrc
|
||||
83:eval "$(zoxide init --cmd j zsh)"
|
||||
107:eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
|
||||
```
|
||||
|
||||
[https://docs.rs/regex/*/regex/#syntax](https://docs.rs/regex/*/regex/#syntax)
|
||||
|
||||
rg dans tout un répertoire:
|
||||
|
||||
```bash
|
||||
$ rg '#!'
|
||||
handbrake-batchconvert.sh
|
||||
1:#!/bin/sh
|
||||
|
||||
composer.sh
|
||||
1:#!/bin/bash
|
||||
|
||||
tmutil.sh
|
||||
1:#!/bin/bash
|
||||
```
|
||||
|
||||
```bash
|
||||
$ rg '#!' Scripts
|
||||
Scripts/kymsu2/kymsu2.sh
|
||||
1:#!/usr/bin/env bash
|
||||
|
||||
Scripts/sonos/test.sh
|
||||
1:#!/usr/bin/env bash
|
||||
```
|
||||
|
||||
En l'absence de chemin, rg cherche dans le répertoire courant.
|
||||
|
||||
##### Filtre manuel:
|
||||
|
||||
```bash
|
||||
# Rechercher uniquement dans les fichiers .sh
|
||||
rg echo -g '*.sh'
|
||||
|
||||
# Rechercher partout sauf dans les fichiers .sh
|
||||
rg echo -g '!*.sh'
|
||||
```
|
||||
|
||||
##### File types
|
||||
|
||||
```bash
|
||||
$ rg --type-list
|
||||
...
|
||||
config: *.cfg, *.conf, *.config, *.ini
|
||||
md: *.markdown, *.md, *.mdown, *.mkdn
|
||||
php: *.php, *.php3, *.php4, *.php5, *.phtml
|
||||
sh: *.bash, *.bashrc, *.csh, *.cshrc, *.ksh, *.kshrc, *.sh, *.tcsh, *.zsh, .bash_login, .bash_logout, .bash_profile, .bashrc, .cshrc, .kshrc, .login, .logout, .profile, .tcshrc, .zlogin, .zlogout, .zprofile, .zshenv, .zshrc, bash_login, bash_logout, bash_profile, bashrc, profile, zlogin, zlogout, zprofile, zshenv, zshrc
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
# Recherche dans les fichiers shell .bashrc, .zshrc...
|
||||
|
||||
$ rg 'eval' --type sh ~/
|
||||
# ou
|
||||
$ rg 'eval' -tsh ~/
|
||||
/Users/bruno/.bash_profile
|
||||
72:eval "$(thefuck --alias)"
|
||||
/Users/bruno/.zprofile
|
||||
1:eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
...
|
||||
|
||||
# Recherche partout sauf dans les fichiers shell .bashrc, .zshrc...
|
||||
|
||||
$ rg 'eval' --type-not sh ~/
|
||||
# ou
|
||||
$ rg 'eval' -Tsh ~/
|
||||
```
|
||||
|
||||
##### Remplacement:
|
||||
|
||||
```bash
|
||||
# recherche / remplacement mot pour mot
|
||||
$ rg fast README.md --replace FAST
|
||||
$ rg fast README.md -r FAST
|
||||
|
||||
# remplacer toute une ligne
|
||||
$ rg '^.*fast.*$' README.md -r FAST
|
||||
```
|
||||
|
||||
##### Fichier de configuration:
|
||||
|
||||
```bash
|
||||
$ cat $HOME/.ripgreprc
|
||||
```
|
||||
|
||||
|
||||
|
||||
### zoxide (z-zi)(j-ji)
|
||||
|
||||
alternative à *z plugin*
|
||||
|
||||
https://github.com/ajeetdsouza/zoxide
|
||||
|
||||
##### Installation:
|
||||
|
||||
```bash
|
||||
$ brew install zoxide
|
||||
```
|
||||
|
||||
##### Ajout au shell:
|
||||
|
||||
```bash
|
||||
# zsh
|
||||
eval "$(zoxide init zsh)"
|
||||
|
||||
# bash
|
||||
eval "$(zoxide init bash)"
|
||||
```
|
||||
|
||||
##### Installer fzf:
|
||||
|
||||
```bash
|
||||
$ brew install fzf
|
||||
# To install useful key bindings and fuzzy completion:
|
||||
$(brew --prefix)/opt/fzf/install
|
||||
```
|
||||
|
||||
##### Configuration:
|
||||
|
||||
```bash
|
||||
# changer les alias prédéfinis (j au lieu de z):
|
||||
eval "$(zoxide init --cmd j zsh)"
|
||||
|
||||
```
|
||||
|
||||
##### Utilisation:
|
||||
|
||||
```bash
|
||||
z foo # cd into highest ranked directory matching foo
|
||||
z foo bar # cd into highest ranked directory matching foo and bar
|
||||
|
||||
z ~/foo # z also works like a regular cd command
|
||||
z foo/ # cd into relative path
|
||||
z .. # cd one level up
|
||||
z - # cd into previous directory
|
||||
|
||||
zi foo # cd with interactive selection (using fzf)
|
||||
```
|
||||
|
||||
|
||||
@@ -186,6 +186,27 @@ tiger
|
||||
snowleopard
|
||||
```
|
||||
|
||||
Trim toute la colonne:
|
||||
|
||||
```bash
|
||||
$ awk '{$1=$1;print}'
|
||||
```
|
||||
|
||||
Supprimer la 1ere colonne:
|
||||
|
||||
```bash
|
||||
$ awk '{$1=""; print $0}'
|
||||
|
||||
# les 3 premières colonnes
|
||||
$ awk '{$1=$2=$3=""; print $0}'
|
||||
```
|
||||
|
||||
Supprimer la dernière colonne:
|
||||
|
||||
```bash
|
||||
$ awk -F"/" 'BEGIN{OFS=FS} {NF--; print}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Lignes:
|
||||
@@ -195,6 +216,8 @@ Afficher la 3eme ligne:
|
||||
```bash
|
||||
$ awk 'NR==3' test.txt
|
||||
mint
|
||||
|
||||
$ awk 'FNR == 3 {print}'
|
||||
```
|
||||
|
||||
Afficher les ligne 2 à 4:
|
||||
@@ -206,6 +229,30 @@ mint
|
||||
debian
|
||||
```
|
||||
|
||||
Afficher 4e colonne de la 2e ligne:
|
||||
|
||||
```bash
|
||||
$ awk 'NR==2{print $4}'
|
||||
```
|
||||
|
||||
Supprimer les lignes vides:
|
||||
|
||||
```bash
|
||||
$ awk NF
|
||||
```
|
||||
|
||||
Nombre de lignes:
|
||||
|
||||
```bash
|
||||
$ awk 'END { print NR }' test.txt
|
||||
```
|
||||
|
||||
Supprimer tout après la 1ere ligne vide:
|
||||
|
||||
```bash
|
||||
$ awk '/^$/{exit} 1'
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Divers:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# bat
|
||||
|
||||
Remplaçant de cat
|
||||
Remplaçant de *cat*
|
||||
|
||||
https://github.com/sharkdp/bat
|
||||
|
||||
|
||||
@@ -95,6 +95,25 @@ gd.jpeg_ignore_warning = 1 | session.cookie_samesite =
|
||||
|
||||
|
||||
|
||||
##### Comparer un fichier local et un fichier distant:
|
||||
|
||||
```bash
|
||||
$ ssh bruno@212.227.191.167 "cat upgrade_nextcloud.sh" | diff - /Users/bruno/Documents/Scripts/bash/upgrade_nextcloud.sh | colordiff
|
||||
35c35
|
||||
< php_version=7.4
|
||||
---
|
||||
> php_version=8.0
|
||||
|
||||
```
|
||||
|
||||
##### Comparer 2 fichiers distants sur 2 serveurs différents:
|
||||
|
||||
```bash
|
||||
$ diff <(ssh user@remote-host1 'cat /path/to/file1') <(ssh user@remote-host2 'cat /path/to/file2')
|
||||
```
|
||||
|
||||
|
||||
|
||||
Colordiff peut comparer 2 dossiers:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -482,3 +482,8 @@ echo "Input is a string."
|
||||
fi
|
||||
```
|
||||
|
||||
```bash
|
||||
# entier
|
||||
if [ -z "${i//[0-9]}" ]; then
|
||||
```
|
||||
|
||||
|
||||
10
docs/Linux/cut.md
Normal file
10
docs/Linux/cut.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# cut
|
||||
|
||||
|
||||
|
||||
- séparateur par défaut: TAB
|
||||
|
||||
- sinon option -d ' '
|
||||
|
||||
|
||||
|
||||
@@ -12,3 +12,11 @@
|
||||
|
||||
|
||||
|
||||
#### Origine d'un lien:
|
||||
|
||||
```bash
|
||||
/usr/local/bin
|
||||
❯ readlink -f kymsu2
|
||||
/Users/bruno/Documents/Scripts/kymsu2/kymsu2.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -1,9 +1,29 @@
|
||||
# exa
|
||||
|
||||
Remplaçant de *ls*
|
||||
|
||||
https://the.exa.website
|
||||
|
||||
Installation:
|
||||
|
||||
```bash
|
||||
$ brew install exa
|
||||
```
|
||||
|
||||
|
||||
|
||||
exa n'est plus maintenant. Il est remplacé par eza.
|
||||
|
||||
# eza
|
||||
|
||||
https://github.com/eza-community/eza
|
||||
|
||||
|
||||
|
||||
**exa -lbhHigUmuSa@ --time-style=long-iso --git --color-scale**
|
||||
|
||||
```bash
|
||||
❯ exa -lbhHigUmuSa@ --time-style=long-iso --git --color-scale
|
||||
$ exa -lbhHigUmuSa@ --time-style=long-iso --git --color-scale
|
||||
inode Permissions Links Size Blocks User Group Date Modified Date Created Date Accessed Git Name
|
||||
3426575 drwxr-xr-x 12 - - bruno staff 2021-08-05 17:33 2021-08-05 09:35 2021-08-05 17:33 -- .git
|
||||
3426645 drwxr-xr-x 3 - - bruno staff 2021-08-05 09:35 2021-08-05 09:35 2021-08-05 17:32 -- img
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
(alternative à [find](find.md)) (macOS / Linux / Windows)
|
||||
|
||||
https://github.com/sharkdp/fd
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
$ brew install fd
|
||||
```
|
||||
|
||||
@@ -65,6 +65,14 @@ $ find /usr -name toto -type f
|
||||
$ find /usr -name toto -type d
|
||||
```
|
||||
|
||||
Ne pas afficher les fichiers ou dossiers invisibles:
|
||||
|
||||
```bash
|
||||
$find -not -path '*/\.*'
|
||||
|
||||
$find . -type f | grep -v '/\.'
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Taille:
|
||||
|
||||
@@ -27,14 +27,85 @@ Parcourir les arguments passés au script:
|
||||
```bash
|
||||
for i in "$@"
|
||||
do
|
||||
echo "$i"
|
||||
echo "Hi $i"
|
||||
done
|
||||
```
|
||||
|
||||
Parcourrir une liste:
|
||||
|
||||
```bash
|
||||
for i in {1..5}
|
||||
do
|
||||
echo "Hi $i"
|
||||
done
|
||||
|
||||
Hi 1
|
||||
Hi 2
|
||||
Hi 3
|
||||
Hi 4
|
||||
Hi 5
|
||||
```
|
||||
|
||||
```bash
|
||||
# bash 4.0+
|
||||
for i in {0. .8. .2} # debut. .fin. .increment
|
||||
do
|
||||
echo "Hi $i"
|
||||
done
|
||||
|
||||
Hi 0
|
||||
Hi 2
|
||||
Hi 4
|
||||
Hi 6
|
||||
Hi 8
|
||||
```
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
for ((i=0 ; 10 - $i ; i++))
|
||||
do echo $i
|
||||
do
|
||||
echo "Hi $i"
|
||||
done
|
||||
```
|
||||
```
|
||||
|
||||
```bash
|
||||
for (( c=1; c<=5; c++ ))
|
||||
do
|
||||
echo "Hi $c"
|
||||
done
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Continue
|
||||
|
||||
```bash
|
||||
for i in {1..5}
|
||||
do
|
||||
[[ "$i" == '4' ]] && continue;
|
||||
echo "Hi $i"
|
||||
done
|
||||
|
||||
Hi 1
|
||||
Hi 2
|
||||
Hi 3
|
||||
Hi 5
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Break
|
||||
|
||||
```bash
|
||||
for i in {1..5}
|
||||
do
|
||||
[[ "$i" == '4' ]] && break;
|
||||
echo "Hi $i"
|
||||
done
|
||||
|
||||
Hi 1
|
||||
Hi 2
|
||||
Hi 3
|
||||
```
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ $ cat **
|
||||
|
||||
Puis **Tab**
|
||||
|
||||

|
||||
<img src="/Users/bruno/Documents/docs/docs/Linux/fzf5.png" alt="fzf5" style="zoom:100%;" />
|
||||
|
||||
Puis **Return**
|
||||
|
||||
@@ -173,7 +173,7 @@ $ nano /opt/**
|
||||
|
||||
Puis **Tab**
|
||||
|
||||

|
||||
<img src="/Users/bruno/Documents/docs/docs/Linux/fzf6.png" alt="fzf6" style="zoom:100%;" />
|
||||
|
||||
Puis **Return**
|
||||
|
||||
@@ -220,6 +220,22 @@ https://bluz71.github.io/2018/11/26/fuzzy-finding-in-bash-with-fzf.html
|
||||
|
||||
https://curatedgo.com/r/fzf-is-a-junegunnfzf/index.html
|
||||
|
||||
https://thevaluable.dev/practical-guide-fzf-example/
|
||||
|
||||
https://pragmaticpineapple.com/four-useful-fzf-tricks-for-your-terminal/
|
||||
|
||||
https://reposhub.com/linux/shell-applications/lincheney-fzf-tab-completion.html
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
function activate-venv() {
|
||||
local selected_env
|
||||
selected_env=$(ls ~/.venv/ | fzf)
|
||||
|
||||
if [ -n "$selected_env" ]; then
|
||||
source "$HOME/.venv/$selected_env/bin/activate"
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
###
|
||||
@@ -22,7 +22,7 @@
|
||||
| **-f** file, **--file**=file<br />Lisez un ou plusieurs modèles séparés de saut de ligne du fichier. Les lignes de motif vides correspondent à chaque ligne d'entrée. Les sauts de ligne ne sont pas considérés comme faisant partie d'un modèle. Si le fichier est vide, rien n'est trouvé. | **-f** FILE, **--file**=FILE<br/>Obtenez des modèles à partir de FILE, un par ligne. Si cette option est utilisée plusieurs fois ou est combinée avec l'option **-e** (**--regexp**), recherchez tous les modèles donnés. Le fichier vide ne contient aucun motif et ne correspond donc à rien. |
|
||||
| **-G**, **--basic-regexp**<br />Interpréter le motif comme une expression régulière de base. | **-G**, **--basic-regexp**<br/>Interpréter les MODÈLES comme des expressions régulières de base (BRE, voir ci- dessous). C'est la valeur par défaut. |
|
||||
| **-H**<br />Affchez toujours les en-têtes de nom de fichier avec des lignes de sortie. | **-H**, **--with-filename**<br/>Affchez le nom du fichier pour chaque correspondance. C'est la valeur par défaut lorsqu'il y a plus d'un fichier à rechercher. |
|
||||
| **-h**, **--no-filename**<br/>N'affchez jamais d'en-têtes de nom de fichier (c'est-à-dire des noms de fichier) avec des lignes de sortie. | **-h**, **--no-filename**<br/>Supprimez le préfixe des noms de fichiers sur la sortie. C'est la valeur par défaut lorsqu'il n'y a qu'un seul fichier (ou une seule entrée standard) à rechercher. |
|
||||
| **-h**, **--no-filename**<br/>N'affichez jamais d'en-têtes de nom de fichier (c'est-à-dire des noms de fichier) avec des lignes de sortie. | **-h**, **--no-filename**<br/>Supprimez le préfixe des noms de fichiers sur la sortie. C'est la valeur par défaut lorsqu'il n'y a qu'un seul fichier (ou une seule entrée standard) à rechercher. |
|
||||
| **--help**<br />Imprimez un bref message d'aide. | **--help**<br />Affchez un message d'utilisation et quittez. |
|
||||
| **-I**<br />Ignorez les fichiers binaires. Cette option est équivalente à l'option **--binary-file=without-match**. | **-I**<br />Traiter un fichier binaire comme s'il ne contenait pas de données correspondantes ; c'est équivalent à l'option **--binary-files=without-match**. |
|
||||
| **--include**<br />Si spécifié, seuls les fichiers correspondant au modèle de nom de fichier donné sont recherchés. Notez que les modèles **--exclude** ont priorité sur **-- include** patterns. Les motifs correspondent au chemin d'accès complet spécifié, pas seulement au composant nom de fichier. | **--include**=GLOB<br/>Recherchez uniquement les fichiers dont le nom de base correspond à GLOB (en utilisant la correspondance de caractères génériques comme décrit sous **-- exclude**).<br/> Si des options contradictoires **--include** et **--exclude** sont données, la dernière correspondante gagne.<br/> Si aucune option **--include** ou **--exclude ne** correspond, un fichier est inclus à moins que la première de ces options ne soit **--include**. |
|
||||
|
||||
@@ -121,6 +121,12 @@ Lignes commençant par les caractères compris entre a et d:
|
||||
grep ^[a-d] fichier.txt
|
||||
```
|
||||
|
||||
Lignes ne commençant pas # ou ;
|
||||
|
||||
```bash
|
||||
grep "^[^#;]" smb.conf
|
||||
```
|
||||
|
||||
|
||||
|
||||
Rechercher plusieurs chaines:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Linux
|
||||
|
||||
[Authentification automatique par SSH sans mot de passe](../macos/ssh/ssh-passwordless.md)
|
||||
[Authentification automatique par SSH sans mot de passe](../macOS/ssh/ssh-passwordless.md)
|
||||
|
||||
[Archiver / compresser](archiver.md)
|
||||
|
||||
|
||||
78
docs/Linux/links.md
Normal file
78
docs/Linux/links.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# Links
|
||||
|
||||
|
||||
|
||||
### soft link (symbolic link):
|
||||
|
||||
- ln -s
|
||||
- contient le chemin du fichier original
|
||||
- link des répertoires
|
||||
|
||||
```bash
|
||||
~ mkdir link
|
||||
|
||||
~ touch link/hello.txt
|
||||
|
||||
~ ln -s link/hello.txt
|
||||
|
||||
~ ls
|
||||
hello.txt link
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Créer un lien symbolic
|
||||
|
||||
```bash
|
||||
~ ln -s link/hello.txt hello_you.txt
|
||||
|
||||
~❯ ls
|
||||
hello.txt link hello_you.txt
|
||||
```
|
||||
|
||||
|
||||
|
||||
### hard link:
|
||||
|
||||
- ln
|
||||
- contient le contenu du fichier original (le hardlink et le fichier original partagent le même inode)
|
||||
- ne link pas des répertoires
|
||||
|
||||
|
||||
|
||||
#### Inode number
|
||||
|
||||
```bash
|
||||
~ touch file_1 file_2
|
||||
|
||||
~ ls -i
|
||||
43767553 file_1 43767554 file_2
|
||||
```
|
||||
|
||||
```bash
|
||||
~ ls -l
|
||||
-rw-r--r-- 1 bruno staff 0 mai 6 18:29 file_1
|
||||
-rw-r--r-- 1 bruno staff 0 mai 6 18:29 file_2
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Créer un hard-link
|
||||
|
||||
```bash
|
||||
~ ln file_1 hard_ln
|
||||
```
|
||||
|
||||
```bash
|
||||
~ ls -li
|
||||
43767553 -rw-r--r-- 2 bruno staff 0 mai 6 18:29 file_1
|
||||
43767554 -rw-r--r-- 1 bruno staff 0 mai 6 18:29 file_2
|
||||
43767553 -rw-r--r-- 2 bruno staff 0 mai 6 18:29 hard_ln
|
||||
43768356 lrwxr-xr-x 1 bruno staff 14 mai 6 18:46 hello.txt -> link/hello.txt
|
||||
43768828 lrwxr-xr-x 1 bruno staff 14 mai 6 18:50 hello_you.txt -> link/hello.txt
|
||||
43768326 drwxr-xr-x 3 bruno staff 96 mai 6 18:46 link
|
||||
```
|
||||
|
||||
file_1 et hard_ln ont le même inode.
|
||||
|
||||
Si on supprime `file_1`, `hard_ln` conserve le même contenu.
|
||||
234
docs/Linux/locale.md
Normal file
234
docs/Linux/locale.md
Normal file
@@ -0,0 +1,234 @@
|
||||
# locale
|
||||
|
||||
|
||||
|
||||
Connaitre la locale:
|
||||
|
||||
```bash
|
||||
$ locale
|
||||
LANG="fr_FR.UTF-8"
|
||||
LC_COLLATE="fr_FR.UTF-8"
|
||||
LC_CTYPE="fr_FR.UTF-8"
|
||||
LC_MESSAGES="fr_FR.UTF-8"
|
||||
LC_MONETARY="fr_FR.UTF-8"
|
||||
LC_NUMERIC="fr_FR.UTF-8"
|
||||
LC_TIME="fr_FR.UTF-8"
|
||||
LC_ALL=
|
||||
```
|
||||
|
||||
Connaitre toutes les locales:
|
||||
|
||||
```bash
|
||||
$ locale -a
|
||||
en_NZ
|
||||
nl_NL.UTF-8
|
||||
pt_BR.UTF-8
|
||||
fr_CH.ISO8859-15
|
||||
eu_ES.ISO8859-15
|
||||
en_US.US-ASCII
|
||||
af_ZA
|
||||
bg_BG
|
||||
cs_CZ.UTF-8
|
||||
fi_FI
|
||||
zh_CN.UTF-8
|
||||
eu_ES
|
||||
sk_SK.ISO8859-2
|
||||
nl_BE
|
||||
fr_BE
|
||||
sk_SK
|
||||
en_US.UTF-8
|
||||
en_NZ.ISO8859-1
|
||||
de_CH
|
||||
sk_SK.UTF-8
|
||||
de_DE.UTF-8
|
||||
am_ET.UTF-8
|
||||
zh_HK
|
||||
be_BY.UTF-8
|
||||
uk_UA
|
||||
pt_PT.ISO8859-1
|
||||
en_AU.US-ASCII
|
||||
kk_KZ.PT154
|
||||
en_US
|
||||
nl_BE.ISO8859-15
|
||||
de_AT.ISO8859-1
|
||||
hr_HR.ISO8859-2
|
||||
fr_FR.ISO8859-1
|
||||
af_ZA.UTF-8
|
||||
am_ET
|
||||
fi_FI.ISO8859-1
|
||||
ro_RO.UTF-8
|
||||
af_ZA.ISO8859-15
|
||||
en_NZ.UTF-8
|
||||
fi_FI.UTF-8
|
||||
hr_HR.UTF-8
|
||||
da_DK.UTF-8
|
||||
ca_ES.ISO8859-1
|
||||
en_AU.ISO8859-15
|
||||
ro_RO.ISO8859-2
|
||||
de_AT.UTF-8
|
||||
pt_PT.ISO8859-15
|
||||
sv_SE
|
||||
fr_CA.ISO8859-1
|
||||
fr_BE.ISO8859-1
|
||||
en_US.ISO8859-15
|
||||
it_CH.ISO8859-1
|
||||
en_NZ.ISO8859-15
|
||||
en_AU.UTF-8
|
||||
de_AT.ISO8859-15
|
||||
af_ZA.ISO8859-1
|
||||
hu_HU.UTF-8
|
||||
et_EE.UTF-8
|
||||
he_IL.UTF-8
|
||||
uk_UA.KOI8-U
|
||||
be_BY
|
||||
kk_KZ
|
||||
hu_HU.ISO8859-2
|
||||
it_CH
|
||||
pt_BR
|
||||
ko_KR
|
||||
it_IT
|
||||
fr_BE.UTF-8
|
||||
ru_RU.ISO8859-5
|
||||
zh_TW
|
||||
zh_CN.GB2312
|
||||
no_NO.ISO8859-15
|
||||
de_DE.ISO8859-15
|
||||
en_CA
|
||||
fr_CH.UTF-8
|
||||
sl_SI.UTF-8
|
||||
uk_UA.ISO8859-5
|
||||
pt_PT
|
||||
hr_HR
|
||||
cs_CZ
|
||||
fr_CH
|
||||
he_IL
|
||||
zh_CN.GBK
|
||||
zh_CN.GB18030
|
||||
fr_CA
|
||||
pl_PL.UTF-8
|
||||
ja_JP.SJIS
|
||||
sr_YU.ISO8859-5
|
||||
be_BY.CP1251
|
||||
sr_YU.ISO8859-2
|
||||
sv_SE.UTF-8
|
||||
sr_YU.UTF-8
|
||||
de_CH.UTF-8
|
||||
sl_SI
|
||||
pt_PT.UTF-8
|
||||
ro_RO
|
||||
en_NZ.US-ASCII
|
||||
ja_JP
|
||||
zh_CN
|
||||
fr_CH.ISO8859-1
|
||||
ko_KR.eucKR
|
||||
be_BY.ISO8859-5
|
||||
nl_NL.ISO8859-15
|
||||
en_GB.ISO8859-1
|
||||
en_CA.US-ASCII
|
||||
is_IS.ISO8859-1
|
||||
ru_RU.CP866
|
||||
nl_NL
|
||||
fr_CA.ISO8859-15
|
||||
sv_SE.ISO8859-15
|
||||
hy_AM
|
||||
en_CA.ISO8859-15
|
||||
en_US.ISO8859-1
|
||||
zh_TW.Big5
|
||||
ca_ES.UTF-8
|
||||
ru_RU.CP1251
|
||||
en_GB.UTF-8
|
||||
en_GB.US-ASCII
|
||||
ru_RU.UTF-8
|
||||
eu_ES.UTF-8
|
||||
es_ES.ISO8859-1
|
||||
hu_HU
|
||||
el_GR.ISO8859-7
|
||||
en_AU
|
||||
it_CH.UTF-8
|
||||
en_GB
|
||||
sl_SI.ISO8859-2
|
||||
ru_RU.KOI8-R
|
||||
nl_BE.UTF-8
|
||||
et_EE
|
||||
fr_FR.ISO8859-15
|
||||
cs_CZ.ISO8859-2
|
||||
lt_LT.UTF-8
|
||||
pl_PL.ISO8859-2
|
||||
fr_BE.ISO8859-15
|
||||
is_IS.UTF-8
|
||||
tr_TR.ISO8859-9
|
||||
da_DK.ISO8859-1
|
||||
lt_LT.ISO8859-4
|
||||
lt_LT.ISO8859-13
|
||||
zh_TW.UTF-8
|
||||
bg_BG.CP1251
|
||||
el_GR.UTF-8
|
||||
be_BY.CP1131
|
||||
da_DK.ISO8859-15
|
||||
is_IS.ISO8859-15
|
||||
no_NO.ISO8859-1
|
||||
nl_NL.ISO8859-1
|
||||
nl_BE.ISO8859-1
|
||||
sv_SE.ISO8859-1
|
||||
pt_BR.ISO8859-1
|
||||
zh_CN.eucCN
|
||||
it_IT.UTF-8
|
||||
en_CA.UTF-8
|
||||
uk_UA.UTF-8
|
||||
de_CH.ISO8859-15
|
||||
de_DE.ISO8859-1
|
||||
ca_ES
|
||||
sr_YU
|
||||
hy_AM.ARMSCII-8
|
||||
ru_RU
|
||||
zh_HK.UTF-8
|
||||
eu_ES.ISO8859-1
|
||||
is_IS
|
||||
bg_BG.UTF-8
|
||||
ja_JP.UTF-8
|
||||
it_CH.ISO8859-15
|
||||
fr_FR.UTF-8
|
||||
ko_KR.UTF-8
|
||||
et_EE.ISO8859-15
|
||||
kk_KZ.UTF-8
|
||||
ca_ES.ISO8859-15
|
||||
en_IE.UTF-8
|
||||
es_ES
|
||||
de_CH.ISO8859-1
|
||||
en_CA.ISO8859-1
|
||||
es_ES.ISO8859-15
|
||||
en_AU.ISO8859-1
|
||||
el_GR
|
||||
da_DK
|
||||
no_NO
|
||||
it_IT.ISO8859-1
|
||||
en_IE
|
||||
zh_HK.Big5HKSCS
|
||||
hi_IN.ISCII-DEV
|
||||
ja_JP.eucJP
|
||||
it_IT.ISO8859-15
|
||||
pl_PL
|
||||
ko_KR.CP949
|
||||
fr_CA.UTF-8
|
||||
fi_FI.ISO8859-15
|
||||
en_GB.ISO8859-15
|
||||
fr_FR
|
||||
hy_AM.UTF-8
|
||||
no_NO.UTF-8
|
||||
es_ES.UTF-8
|
||||
de_AT
|
||||
tr_TR.UTF-8
|
||||
de_DE
|
||||
lt_LT
|
||||
tr_TR
|
||||
C
|
||||
POSIX
|
||||
```
|
||||
|
||||
Liste de tous les mots-clés et catégories:
|
||||
|
||||
```bash
|
||||
$ locale -ck LC_ALL
|
||||
|
||||
```
|
||||
|
||||
126
docs/Linux/ripgrep.md
Normal file
126
docs/Linux/ripgrep.md
Normal file
@@ -0,0 +1,126 @@
|
||||
# ripgrep (rg)
|
||||
|
||||
Remplaçant de *grep*
|
||||
|
||||
https://github.com/BurntSushi/ripgrep
|
||||
|
||||
|
||||
|
||||
##### Installation:
|
||||
|
||||
```bash
|
||||
$ brew install ripgrep
|
||||
```
|
||||
|
||||
##### Utilisation:
|
||||
|
||||
```bash
|
||||
$ rg PATH ~/.zshrc
|
||||
```
|
||||
|
||||
<img src="/Users/bruno/Documents/docs/docs/Linux/rg.png" alt="rg" style="zoom:50%;" />
|
||||
|
||||
```bash
|
||||
# regex ('core' plus 1 ou plusiers lettres)
|
||||
$ rg 'core\w+' ~/.zshrc
|
||||
22:PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH
|
||||
25:coreutils=false
|
||||
|
||||
# regex ('core' plus 0 ou plusiers lettres)
|
||||
$ rg 'core\w*' ~/.zshrc
|
||||
22:PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH
|
||||
25:coreutils=false
|
||||
|
||||
# string
|
||||
$ rg -F 'eval "$(' ~/.zshrc
|
||||
83:eval "$(zoxide init --cmd j zsh)"
|
||||
107:eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
|
||||
```
|
||||
|
||||
[https://docs.rs/regex/*/regex/#syntax](https://docs.rs/regex/*/regex/#syntax)
|
||||
|
||||
rg dans tout un répertoire:
|
||||
|
||||
```bash
|
||||
$ rg '#!'
|
||||
handbrake-batchconvert.sh
|
||||
1:#!/bin/sh
|
||||
|
||||
composer.sh
|
||||
1:#!/bin/bash
|
||||
|
||||
tmutil.sh
|
||||
1:#!/bin/bash
|
||||
```
|
||||
|
||||
```bash
|
||||
$ rg '#!' Scripts
|
||||
Scripts/kymsu2/kymsu2.sh
|
||||
1:#!/usr/bin/env bash
|
||||
|
||||
Scripts/sonos/test.sh
|
||||
1:#!/usr/bin/env bash
|
||||
```
|
||||
|
||||
En l'absence de chemin, rg cherche dans le répertoire courant.
|
||||
|
||||
##### Filtre manuel:
|
||||
|
||||
```bash
|
||||
# Rechercher uniquement dans les fichiers .sh
|
||||
rg echo -g '*.sh'
|
||||
|
||||
# Rechercher partout sauf dans les fichiers .sh
|
||||
rg echo -g '!*.sh'
|
||||
```
|
||||
|
||||
##### File types
|
||||
|
||||
```bash
|
||||
$ rg --type-list
|
||||
...
|
||||
config: *.cfg, *.conf, *.config, *.ini
|
||||
md: *.markdown, *.md, *.mdown, *.mkdn
|
||||
php: *.php, *.php3, *.php4, *.php5, *.phtml
|
||||
sh: *.bash, *.bashrc, *.csh, *.cshrc, *.ksh, *.kshrc, *.sh, *.tcsh, *.zsh, .bash_login, .bash_logout, .bash_profile, .bashrc, .cshrc, .kshrc, .login, .logout, .profile, .tcshrc, .zlogin, .zlogout, .zprofile, .zshenv, .zshrc, bash_login, bash_logout, bash_profile, bashrc, profile, zlogin, zlogout, zprofile, zshenv, zshrc
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
# Recherche dans les fichiers shell .bashrc, .zshrc...
|
||||
|
||||
$ rg 'eval' --type sh ~/
|
||||
# ou
|
||||
$ rg 'eval' -tsh ~/
|
||||
/Users/bruno/.bash_profile
|
||||
72:eval "$(thefuck --alias)"
|
||||
/Users/bruno/.zprofile
|
||||
1:eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
...
|
||||
|
||||
# Recherche partout sauf dans les fichiers shell .bashrc, .zshrc...
|
||||
|
||||
$ rg 'eval' --type-not sh ~/
|
||||
# ou
|
||||
$ rg 'eval' -Tsh ~/
|
||||
```
|
||||
|
||||
##### Remplacement:
|
||||
|
||||
```bash
|
||||
# recherche / remplacement mot pour mot
|
||||
$ rg fast README.md --replace FAST
|
||||
$ rg fast README.md -r FAST
|
||||
|
||||
# remplacer toute une ligne
|
||||
$ rg '^.*fast.*$' README.md -r FAST
|
||||
```
|
||||
|
||||
##### Fichier de configuration:
|
||||
|
||||
```bash
|
||||
$ cat $HOME/.ripgreprc
|
||||
```
|
||||
|
||||
@@ -35,7 +35,7 @@ Copie d'un répertoire, avec éventuellement ses sous-répertoires, vers un rép
|
||||
~ scp -r /home/mickael/data/ root@192.168.10.131:/var/www/
|
||||
```
|
||||
|
||||
Si pas port 22
|
||||
Si pas port 22:
|
||||
|
||||
```bash
|
||||
~ scp -r -P 7256 /home/mickael/data/ root@192.168.10.131:/var/www/
|
||||
@@ -46,6 +46,13 @@ bruno@clicclac.synology.me's password:
|
||||
IPTV.bundle-master.zip 100% 673KB 84.0KB/s 00:08
|
||||
```
|
||||
|
||||
SCP to synology NAS:
|
||||
|
||||
```bash
|
||||
# option -O
|
||||
scp -v -O -P 7256 -r $HOME//Documents/Scripts/bash/template.txt bruno@clicclac.synology.me:/volume1/web/photos/img/
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Serveur -> Client
|
||||
|
||||
@@ -328,6 +328,14 @@ debian
|
||||
raspbian
|
||||
```
|
||||
|
||||
Afficher les <u>n emes lignes</u>:
|
||||
|
||||
```bash
|
||||
# affiche les lignes 3..6..9..
|
||||
# GNU sed
|
||||
$ sed -n '0~3p' test.txt
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Supression de caractères:
|
||||
@@ -405,7 +413,7 @@ debian
|
||||
raspbian
|
||||
```
|
||||
|
||||
Supprimer le dernier caractère de chaque ligne, mais seulement celui spécifié (ici le 'u'):
|
||||
Supprimer le dernier caractère de chaque ligne, mais seulement celui spécifié (ici le 'n'):
|
||||
|
||||
```bash
|
||||
$ sed 's/n$//' test.txt
|
||||
@@ -668,6 +676,100 @@ rAspbiAn
|
||||
|
||||
|
||||
|
||||
#### Ajout de caractères:
|
||||
|
||||
Ajouter un (ou plusieurs) caractère (#) en début de ligne:
|
||||
|
||||
```bash
|
||||
$ sed 's/^/#/' test.txt
|
||||
#red hat
|
||||
#ubuntu
|
||||
#mint
|
||||
#debian
|
||||
#raspbian
|
||||
|
||||
$ sed 's/^/#Prefixe: &/' test.txt
|
||||
#Prefixe: red hat
|
||||
#Prefixe: ubuntu
|
||||
#Prefixe: mint
|
||||
#Prefixe: debian
|
||||
#Prefixe: raspbian
|
||||
|
||||
# Pour modifier le fichiet
|
||||
$ sed -i 's/^/#/' file.txt
|
||||
```
|
||||
|
||||
Ajouter un (ou plusieurs) caractère (#) en fin de ligne:
|
||||
|
||||
```bash
|
||||
$ sed 's/$/#/' test.txt
|
||||
red hat#
|
||||
ubuntu#
|
||||
mint#
|
||||
debian#
|
||||
raspbian#
|
||||
|
||||
$ sed 's/$/ _suffixe/' test.txt
|
||||
red hat _suffixe
|
||||
ubuntu _suffixe
|
||||
mint _suffixe
|
||||
debian _suffixe
|
||||
raspbian _suffixe
|
||||
|
||||
# Pour modifier le fichiet
|
||||
$ sed -i 's/$/#/' file.txt
|
||||
```
|
||||
|
||||
Ajouter un (ou plusieurs) caractère (#) en début d'une ligne précise:
|
||||
|
||||
```bash
|
||||
$ sed 2's/^/#Prefixe: &/' test.txt
|
||||
red hat
|
||||
#Prefixe: ubuntu
|
||||
mint
|
||||
debian
|
||||
raspbian
|
||||
```
|
||||
|
||||
Si on ne connait pas le numéro de ligne:
|
||||
|
||||
```bash
|
||||
$ sed 's/ubuntu/Prefixe: &/' test.txt
|
||||
red hat
|
||||
Prefixe: ubuntu
|
||||
mint
|
||||
debian
|
||||
raspbian
|
||||
|
||||
# ou trouver le numero:
|
||||
$ grep -n "ubuntu" test.txt | cut -d: -f -1
|
||||
2
|
||||
```
|
||||
|
||||
Ajouter un (ou plusieurs) caractère (#) en fin d'une ligne précise:
|
||||
|
||||
```bash
|
||||
$ sed 3's/$/ _suffixe &/' test.txt
|
||||
red hat
|
||||
ubuntu
|
||||
mint _suffixe
|
||||
debian
|
||||
raspbian
|
||||
```
|
||||
|
||||
Ajouter un (ou plusieurs) caractère en début ET en fin d'une ligne précise:
|
||||
|
||||
```bash
|
||||
$ sed 2's/.*/#Prefixe: & _suffixe/' test.txt
|
||||
red hat
|
||||
#Prefixe: ubuntu _suffixe
|
||||
mint
|
||||
debian
|
||||
raspbian
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Ajouter une ligne (à voir pour macOS):
|
||||
|
||||
Ajouter une ligne d'entête:
|
||||
|
||||
@@ -64,12 +64,21 @@ MemTotal: 1963472 kB
|
||||
#### Exécuter un script distant sur un serveur distant:
|
||||
|
||||
```bash
|
||||
bruno@SilverBook:~$ ssh -p34987 bruno@xxxxxxx.synology.me ./test.sh
|
||||
$ ssh -p34987 bruno@xxxxxxx.synology.me ./test.sh
|
||||
bruno@clicclac.synology.me's password:
|
||||
09:55:03 up 2 days, 21:49, 0 users, load average: 1.14, 1.25, 1.23
|
||||
DS916
|
||||
```
|
||||
|
||||
Si le script nécessite un sudo:
|
||||
|
||||
```bash
|
||||
$ ssh -t bruno@maboiteverte.fr ./purge_server.sh
|
||||
|
||||
# sinon erreur:
|
||||
# sudo: no tty present and no askpass program specified
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Exécuter un script local sur un serveur distant:
|
||||
|
||||
@@ -28,6 +28,14 @@ $ tail -n 15 /var/log/messages
|
||||
$ tail -f /var/log/messages
|
||||
```
|
||||
|
||||
Supprimer la 1ere ligne
|
||||
|
||||
```bash
|
||||
$ tail -n+2
|
||||
|
||||
$ awk NR\>1
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Head
|
||||
@@ -40,6 +48,14 @@ $ head -n5 /var/log/messages
|
||||
$ head -n 5 /var/log/messages
|
||||
```
|
||||
|
||||
Supprime la dernière ligne
|
||||
|
||||
```bash
|
||||
$ head -n -1
|
||||
|
||||
$ awk 'NR>1{print p}{p=$0}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
### MultiTail
|
||||
|
||||
52
docs/Linux/zoxide.md
Normal file
52
docs/Linux/zoxide.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# zoxide (z-zi)(j-ji)
|
||||
|
||||
https://github.com/ajeetdsouza/zoxide
|
||||
|
||||
|
||||
|
||||
##### Installation:
|
||||
|
||||
```bash
|
||||
$ brew install zoxide
|
||||
```
|
||||
|
||||
##### Ajout au shell:
|
||||
|
||||
```bash
|
||||
# zsh
|
||||
eval "$(zoxide init zsh)"
|
||||
|
||||
# bash
|
||||
eval "$(zoxide init bash)"
|
||||
```
|
||||
|
||||
##### Installer fzf:
|
||||
|
||||
```bash
|
||||
$ brew install fzf
|
||||
# To install useful key bindings and fuzzy completion:
|
||||
$(brew --prefix)/opt/fzf/install
|
||||
```
|
||||
|
||||
##### Configuration:
|
||||
|
||||
```bash
|
||||
# changer les alias prédéfinis (j au lieu de z):
|
||||
eval "$(zoxide init --cmd j zsh)"
|
||||
|
||||
```
|
||||
|
||||
##### Utilisation:
|
||||
|
||||
```bash
|
||||
z foo # cd into highest ranked directory matching foo
|
||||
z foo bar # cd into highest ranked directory matching foo and bar
|
||||
|
||||
z ~/foo # z also works like a regular cd command
|
||||
z foo/ # cd into relative path
|
||||
z .. # cd one level up
|
||||
z - # cd into previous directory
|
||||
|
||||
zi foo # cd with interactive selection (using fzf)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user