Tee (Unix)

ls -l werden über tee zum einen zu dem Pager less geleitet, zum anderen in die Datei file.txt. Das Stream-Verlaufsdiagramm sieht aus wie ein T-Stück, daher der Name.tee [] ist ein Standard-Unix-Kommando. Sein Name leitet sich von dem T-Stück (engl. tee connector) ab, mit dem Installateure eine Abzweigung in eine Leitung einbauen.
Der Befehl liest Daten von stdin und gibt sie nach stdout und in eine oder mehreren Dateien aus. Er wird benutzt, um Zwischenergebnisse innerhalb einer Pipe zu erhalten. Diese können zur Fehleranalyse herangezogen oder auch in anderen Pipes weiterverarbeitet werden.
Existenz und Funktionsumfang sowie Verhalten dieses Kommandos wird sowohl durch die Single UNIX Specification (SUS)[1] als auch durch den POSIX-Standard genormt, entsprechend dem IEEE-Standard 1003.1 aus dem Jahr 1990.
Dem Standard gemäß versteht tee zwei Optionen: Mit -a wird an die angegebene Datei angehängt (anstatt eine neue leere Datei zu eröffnen) und mit -i wird das Signal SIGINT ignoriert.
Der Befehl ist auch in den GNU Core Utilities enthalten. Außerdem existiert eine native Implementierung für Microsoft Windows[2].
Beispiel
Dieses Beispiel filtert die Dateien und Verzeichnisse im Rootverzeichnis nach allen, die ein b enthalten. Gleichzeitig wird eine Datei out.file angelegt mit allen Dateien und Verzeichnissen im Rootverzeichnis.
ls -l / | tee out.file | grep b
Weblinks
tee: duplicate standard input – Open Group Base Specificationtee(1): pipe fitting – OpenBSD General Commands Manualtee(1): Von Standardeingabe lesen und in Standardausgabe und Dateien schreiben – Debian GNU/Linux Ausführbare Programme oder Shell-Befehle Handbuchseite
Einzelnachweise
- ↑ tee. Single Unix® Specification, Version 2. Open Group, 1997, abgerufen am 6. Mai 2013 (englisch).
- ↑ tee for Windows auf GitHub.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.