Btrunc

From Scriptwiki
Jump to: navigation, search

This truncates/extends a file to the specified length.

btrunc <filename> <bytes>

Examples

;Create a file of 15 bytes, (13 for the text plus 2 for $crlf)
write -c btrunc.test Hi I am Dana!
echo -ag File size: $file(btrunc.test).size

;Lets cut it down to only two bytes.
btrunc btrunc.test 2
echo -ag File size after btrunc: $file(btrunc.test).size
echo -ag File content: $read(btrunc.test,1)

;Now lets make the file back to 15 bytes.
btrunc btrunc.test 15
echo -ag File size at end is now: $file(btrunc.test).size

Note

This alias is very rarely used to extend files; usually used to truncate files only.