1er commit
De la docs au format Mkdocs
This commit is contained in:
77
docs/macos/bash_exemples.md
Normal file
77
docs/macos/bash_exemples.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# Bash (exemples)
|
||||
|
||||
|
||||
|
||||
Ajouter un préfixe à la ligne d'un fichier texte:
|
||||
|
||||
```bash
|
||||
brew list | sed -e 's/^/brew install /' > brew-list.txt
|
||||
```
|
||||
|
||||
Pour un suffixe:
|
||||
|
||||
```bash
|
||||
sed -e 's/$/suffix/'
|
||||
```
|
||||
|
||||
|
||||
|
||||
Cherche tous les .jpg d'un répertoire et les effacer:
|
||||
|
||||
```bash
|
||||
find . -name '*jpg' -exec rm {} +
|
||||
```
|
||||
|
||||
|
||||
|
||||
Concaténer tous les .csv:
|
||||
|
||||
```bash
|
||||
find . -type f -iname "*.csv" -exec cat {} \; > toutes.txt
|
||||
```
|
||||
|
||||
|
||||
Couleurs dans le terminal:
|
||||
|
||||
```bash
|
||||
export UNDERLINE=$(tput sgr 0 1)
|
||||
export BOLD=$(tput bold)
|
||||
export BLACK=$(tput setaf 0)
|
||||
export RED=$(tput setaf 1)
|
||||
export GREEN=$(tput setaf 2)
|
||||
export YELLOW=$(tput setaf 3)
|
||||
export BLUE=$(tput setaf 4)
|
||||
export PURPLE=$(tput setaf 5)
|
||||
export CYAN=$(tput setaf 6)
|
||||
export WHITE=$(tput setaf 7)
|
||||
export GRAY=$(tput setaf 8)
|
||||
export LIGHTRED=$(tput setaf 9)
|
||||
export LIGHTGREEN=$(tput setaf 10)
|
||||
export LIGHTYELLOW=$(tput setaf 11)
|
||||
export LIGHTBLUE=$(tput setaf 12)
|
||||
export LIGHTPURPLE=$(tput setaf 11)
|
||||
export LIGHTCYAN=$(tput setaf 11)
|
||||
export RESET=$(tput sgr0)
|
||||
```
|
||||
|
||||
```bash
|
||||
echo "${BLUE}blue${RESET} ${RED}red${RESET}"
|
||||
blue red
|
||||
for i in {0..255}; do echo "$(tput setaf $i)test"; done
|
||||
|
||||
```
|
||||
|
||||
Supprimer récursivement tous les fichiers .DS_ST0RE:
|
||||
|
||||
```bash
|
||||
sudo find / -name ".DS_Store" -depth -exec rm {} \;
|
||||
```
|
||||
|
||||
```bash
|
||||
find . -name '*.DS_Store' -type f -delete
|
||||
```
|
||||
|
||||
```bash
|
||||
find . -name '.DS_Store' -type f -print -exec rm -f {} +
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user