Cut (Unix)
cut ist ein Unix-Kommando zur spaltenweisen Extraktion von zeilenweise eingelesenem Text.
Zeilensegmente können byte-(-b), zeichen-(-c) oder felderweise (-f) extrahiert werden, wobei mittels -d ein Trennzeichen spezifiziert werden kann. Für Bereichs-Spezifizierungen stehen die Optionen N, N-M, N- (N bis Zeilenende), oder -M
(Zeilenanfang bis M) zur Verfügung.
Die erste bekannte, öffentliche Version von cut war 1982 Bestandteil von Unix System III.[1] In den meisten Linux-Distributionen ist heute die Implementation des Pakets Gnu Core Utilities enthalten, diese wurde von David M. Ihnat, David MacKenzie und Jim Meyering erstellt.[2]
Beispiele
Eine Datei a.tst enthalte folgende Zeilen:
foo:bar:baz:qux:quux
one:two:three:four:five:six:seven
alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu
Mit
% cut -c 4-10 a.tst
lassen sich dann zum Beispiel die 4.–10. Zeichen jeder Zeile ausgeben:
:bar:ba
:two:th
ha:beta
während
% cut -d : -f 5- a.tst
die Zeilen in Felder einteilt, die durch Doppelpunkte separiert sind und unterschiedlich viele Zeichen enthalten können. Jeweils vom fünften solchen Feld an wird dann der Restinhalt der Zeile ausgegeben:
quux
five:six:seven
epsilon:zeta:eta:teta:iota:kappa:lambda:mu
Weblinks
cut: cut out selected fields of each line of a file – Open Group Base Specificationcut(1): select portions of each line of a file – OpenBSD General Commands Manualcut(1): Teile jeder Zeile aus Dateien entfernen – Debian GNU/Linux Ausführbare Programme oder Shell-Befehle Handbuchseite- Cut out selected fields of each line of a file Betrachtung von
cutund dessen historischem Hintergrund
Einzelnachweise
- ↑ Markus Schnalke: Cut out selected fields of each line of a file. In: freiesmagazin. (marmaro.de [PDF]).
- ↑ cut(1): remove sections from each line of files - Linux man page. Abgerufen am 28. März 2020.
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.