truncate
truncate - Größe einer Datei verkleinern oder vergrößern
Beschreibung
Größe einer Datei auf die angegebene Größe verkleinern oder vergrößern
- Eine noch nicht existierende DATEI wird angelegt
Falls eine DATEI größer als angegeben ist, gehen die zusätzlichen Daten verloren
- Ist sie kürzer, wird sie erweitert und der erweiterte Teil (Loch) wird als Nullbytes gelesen
Installation
Aufruf
truncate OPTION… DATEI…
Optionen
Unix | GNU | Parameter | Beschreibung |
---|---|---|---|
-c | --no-create | Keine Dateien erstellen | |
-o | --io-blocks= | GRÖSSE | Anzahl von E/A-Blöcken anstatt Byte behandeln |
-r | --reference= | RDATEI | Größe auf RDATEI basieren |
-s | --size= | GRÖSSE | Setzen oder Anpassen der Dateigröße auf GRÖSSE in Byte |
--help | zeigt Hilfeinformationen an und beendet das Programm | ||
--version | gibt Versionsinformationen aus und beendet das Programm |
GRÖSSE
GRÖSSE ist eine Ganzzahl
Einheit
- Optionale Einheit
- Beispiel
10K ist 10*1024
- Einheiten sind K, M, G, T, P, E, Z, Y, R, Q (Potenzen von 1024) oder KB, MB, … (Potenzen von 1000)
- Es können auch binäre Präfixe verwandt werden: KiB=K, MiB=M und so weiter
Präfixe
GRÖSSE kann auch mit einem der folgenden Zeichen als Präfix versehen werden
+ | erweitern um |
- | verkleinern um |
< | höchstens |
> | mindestens |
/ | abrunden zu Vielfachem von |
% | aufrunden zu Vielfachem von |
Parameter
Umgebungsvariablen
Exit-Status
Wert | Beschreibung |
---|---|
0 | Erfolg |
>0 | Fehler |
Anwendung
Einfache Möglichkeit, ein Sparse-Loch an eine Datei anzuhängen
- truncate ist schneller als dd
- Beispiel
Datei um 10 Byte vergrößern
truncate -s +10 file.txt
siehe: https://serverfault.com/a/343726/70242
TMP
truncate: Shrink or extend the size of a file
truncate
shrinks or extends the size of each file to the specified size.
Synopsis:
truncate option... file...
Any file that does not exist is created.
If a file is larger than the specified size, the extra data is lost. If a file is shorter, it is extended and the sparse extended part (or hole) reads as zero bytes.
The program accepts the following options. Also see Common options.
-c
--no-create
-o
--io-blocks-r rfile
--reference=rfile-s size
--size=size--io-blocks
is specified. size may be, or may be an integer optionally followed by, one of the following multiplicative suffixes:
‘KB’ => 1000 (KiloBytes) ‘K’ => 1024 (KibiBytes) ‘MB’ => 1000*1000 (MegaBytes) ‘M’ => 1024*1024 (MebiBytes) ‘GB’ => 1000*1000*1000 (GigaBytes) ‘G’ => 1024*1024*1024 (GibiBytes)‘+’ => extend by ‘-’ => reduce by ‘<’ => at most ‘>’ => at least ‘/’ => round down to multiple of ‘%’ => round up to multiple of
An exit status of zero indicates success, and a nonzero value indicates failure.
Anhang
Siehe auch
Dokumentation
- Man-Page
Links
Projekt
Weblinks