Truncate a file: Difference between revisions

Content added Content deleted
Line 655: Line 655:
<lang bash># Truncate a file named "myfile" to 1440 kilobytes.
<lang bash># Truncate a file named "myfile" to 1440 kilobytes.
truncate -s 1440k myfile</lang>
truncate -s 1440k myfile</lang>



----
----
Line 731: Line 730:
_EOF_
_EOF_
</lang>
</lang>

# NOTE: Designed for regular text files. Does not work when files contain: chars 0x00 and 0xFF as of bash 4.2 - these chars are treated differently in read -N. For this reason use of method#4 is not prefer over dd(1) or truncate(1) when using binary files, or large files.
NOTE: Designed for regular text files. Does not work when files contain: chars 0x00 and 0xFF as of bash 4.2 - these chars are treated differently in read -N. For this reason use of method#4 is not prefer over dd(1) or truncate(1) when using binary files, or large files. [4b] http://unix.stackexchange.com/questions/8618/script-that-keep-reading-a-stream,[4a] https://groups.google.com/forum/#!topic/gnu.bash.bug/a2rjQHpQYSU


=={{header|ZX Spectrum Basic}}==
=={{header|ZX Spectrum Basic}}==