How can you trim files using the command line?

view story

http://unix.stackexchange.com – What is the console equivalent of the following Python code: target = file("disk", "w") # create a file target.seek(2*1024*1024*1024) # skip to 2 GB target.write("\0") target.close() Maybe some dd incantation? The idea is making a file with the apparent size of 2 GB for use e.g. in virtualization. kvm disk -cd whatever.iso #Only allocate space as necessary (HowTos)