Last active
May 14, 2019 18:34
-
-
Save vbarbarosh/b975cf8d7e51607147bfebac7cd7f6b0 to your computer and use it in GitHub Desktop.
shell_files_truncate – Truncate files https://codescreens.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# Truncate files | |
# Shrink existing file to 4096 bytes | |
truncate -s 4K foo | |
# https://stackoverflow.com/a/18072642/1478566 | |
# Extend file up to 4096 bytes in total (if file is less than this 4K) | |
fallocate -l 4K foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment