Btrunc » History » Version 2
Per Amundsen, 02/09/2014 12:38 AM
| 1 | 1 | Per Amundsen | _Added in 1.9.0_ |
|---|---|---|---|
| 2 | |||
| 3 | */btrunc <filename> <bytes>* |
||
| 4 | |||
| 5 | Truncates/extends a file to the specified length. |
||
| 6 | |||
| 7 | *Parameters* |
||
| 8 | |||
| 9 | <filename> - The file to truncate. |
||
| 10 | <bytes>* - Number of bytes to truncate/extend to. |
||
| 11 | |||
| 12 | *Example* |
||
| 13 | |||
| 14 | 2 | Per Amundsen | <pre> |
| 15 | 1 | Per Amundsen | alias example { |
| 16 | var %temp = Hello! World |
||
| 17 | ;Write to a variable %temp's content |
||
| 18 | bwrite Example 0 $len(%temp) %temp |
||
| 19 | ;Truncate the file down to 6 bytes |
||
| 20 | btrunc Example 6 |
||
| 21 | ;Read the file into a variable |
||
| 22 | bread Example 0 $file(Example).size &Example |
||
| 23 | ;Print out the variable's content |
||
| 24 | echo -a $bvar(&Example,1,$bvar(&Example,0)).text |
||
| 25 | ;Delete the file |
||
| 26 | remove Example |
||
| 27 | } |
||
| 28 | 2 | Per Amundsen | </pre> |