truncate

Truncates all files that match the specified file pattern to the specified length.

The usage is as follows:

$ hadoop fs -truncate [-w] <length> <paths>
Arguments

-w

Waits for the block recovery to complete.
Without the -w flag the file may remain unclosed for some time, while the recovery is in progress.
During this time, the file can’t be reopened for append

Example:

$ hadoop fs -truncate 55 /user/hadoop/file1 /user/hadoop/file2
$ hadoop fs -truncate -w 127 hdfs://nn1.example.com/user/hadoop/file1
Found a mistake? Seleсt text and press Ctrl+Enter to report it