Difference between revisions of "Truncate"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
 
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<code>truncate</code>
+
{{lc}}
 +
<code>truncate</code> (<code>[[coreutils]]</code> package)
  
  
 +
Set file to zero:
 +
* <code>truncate -s 0 /path/to/filename</code>
 +
* <code>truncate -s 0 /var/lib/docker/containers/*/*-json.log</code>
 +
* <code>[[echo]] "" > filename</code>
  
 +
Truncate to a [[size]]:
 +
* <code>truncate -s 500MB [[/swap.img]]</code>
 +
 +
 +
== Related commands ==
 +
* <code>[[virt-resize]]</code>
 +
* <code>[[touch]]</code>
 +
* <code>[[split]]</code>
 +
* <code>[[rm]]</code>
 +
* <code>[[logrotate]]</code>
 +
* <code>[[fallocate]]</code>
 +
* <code>[[tr]]</code>
  
 
== See also ==
 
== See also ==
* {{cat}}
+
* {{coreutils}}
 +
* {{files}}
 +
 
 +
 
 +
 
 +
[[Category:Linux commands]]

Latest revision as of 05:53, 16 March 2023

truncate (coreutils package)


Set file to zero:

  • truncate -s 0 /path/to/filename
  • truncate -s 0 /var/lib/docker/containers/*/*-json.log
  • echo "" > filename

Truncate to a size:


Related commands[edit]

See also[edit]

Advertising: