Difference between writing file from /dev/zero and truncate
4
votes
1
answer
2094
views
$ timeout 1 cat /dev/zero > file1
$ wc -c file1
270422016 file1
$ du file1
264084 file1
Questions :
(1) How do 270422016 null characters come out to be 264084 bytes (i.e 258M).
$ truncate -s 270422016 file2
$ wc -c file2
270422016 file2
$ du file2
0 file2
Questions :
(2)
file2
has been created with same number of null characters as file1
has, but the size of file2
is zero, why?
(3) What did /dev/zero
do that truncate
didn't or vice versa?
Asked by GypsyCosmonaut
(4289 rep)
May 12, 2019, 05:25 AM
Last activity: May 12, 2019, 02:32 PM
Last activity: May 12, 2019, 02:32 PM