66 lines
725 B
Markdown
66 lines
725 B
Markdown
# cut
|
|
|
|
|
|
|
|
- séparateur par défaut: TAB
|
|
|
|
- sinon option -d ' '
|
|
|
|
|
|
|
|
```bash
|
|
# -d (delimiter) :
|
|
# -f (field) 1
|
|
|
|
$ cut -d':' -f1 /etc/passwd
|
|
|
|
nobody
|
|
root
|
|
daemon
|
|
_uucp
|
|
_taskgated
|
|
_networkd
|
|
|
|
cut -d':' -f1-3,5,6 /etc/passwd
|
|
```
|
|
|
|
```bash
|
|
# Tout sauf 7e champ
|
|
|
|
$ cut -d':' -f7 --complement /etc/passwd
|
|
```
|
|
|
|
```bash
|
|
# Remplace le séparateur ':' par ' '
|
|
|
|
$ cut -d':' -f7 --complement /etc/passwd --output-delimiter=' '
|
|
```
|
|
|
|
```bash
|
|
# 5e caractère
|
|
|
|
$ echo 'cut command' | cut -b 5
|
|
c
|
|
|
|
# 5 au 7e caractères
|
|
|
|
$ echo 'cut command' | cut -b 5-7
|
|
com
|
|
|
|
# 5 et 7e caractères
|
|
|
|
$ echo 'cut command' | cut -b 5,7
|
|
cm
|
|
|
|
# Du 5e à la fin
|
|
|
|
$ echo 'cut command' | cut -b 5-
|
|
command
|
|
|
|
# Du début au 5e
|
|
|
|
$ echo 'cut command' | cut -b -5
|
|
cut c
|
|
```
|
|
|