Monday, July 28, 2008

Changing size of a file

How do you change the size of a file in Linux? If you are not concerned about the contents of the file, use the dd command.

dd if=/dev/zero of=/foo/bar bs=1024 count=1
This would change the size of a file to 1 KB. inode number of the file would be preserved.

So if you want to change the size to 2 MB
dd if=/dev/zero of=/foo/bar bs=1024 count=2048

Note that 2 MB is 2048 KB, and not 2000 KB.

No comments:

Post a Comment