Outils pour utilisateurs

Outils du site


linux:ubuntu:redirection_output_commande

Redirection de l'output d'une commande

Source: https://www.howtogeek.com/299219/HOW-TO-SAVE-THE-OUTPUT-OF-A-COMMAND-TO-A-FILE-IN-BASH-AKA-THE-LINUX-AND-MACOS-TERMINAL/

Enregistrer la sortie d'une commande dans un fichier.

Remplace le fichier s'il existe :

$ commande > /path/to/file.txt

Ajoute au fichier s'il existe, sinon en crée un nouveau :

$ commande >> /path/to/file.txt

Si on veut en même temps voir la sortie à l'écran ET l'enregistrer dans un fichier :

$ commande | tee /path/to/file.txt

Ajoute au fichier s'il existe déjà :

$ commande | tree -a /path/to/file.txt
linux/ubuntu/redirection_output_commande.txt · Dernière modification: 2022/01/30 16:28 par marclebrun