There is probably simple trick to do this, but I can't figure from man page.
How do I cut last 1MB from file with undetermined size for example, by using dd?
|
There is probably simple trick to do this, but I can't figure from man page. How do I cut last 1MB from file with undetermined size for example, by using |
|||||||||
|
|
Well, assuming you have
If you want to extract the last
But the saner approach would be to use
|
|||||||||||||
|
dd --help Usage: dd [OPERAND]... or: dd OPTION Copy a file, converting and formatting according to the operands. bs=BYTES read and write BYTES bytes at a time (also see ibs=,obs=) cbs=BYTES convert BYTES bytes at a time conv=CONVS convert the file as per the comma separated symbol list count=BLOCKS copy only BLOCKS input blocks ibs=BYTES read BYTES bytes at a time (default: 512) if=FILE read from FILE instead of stdin iflag=FLAGS read as per the comma separated symbol list obs=BYTES write BYTES bytes at a time (default: 512) of=FILE write to FILE instead of stdout oflag=FLAGS write as per the comma separated symbol list seek=BLOCKS skip BLOCKS obs-sized blocks at start of output skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input status=noxfer suppress transfer statistics BLOCKS and BYTES may be followed by the following multiplicative suffixes: c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y. If the file size is exactly 10MB, 1024*10 10240K This will leave the last 1024K. You should specify the block size you are working with using the ibs and obs options.
You can also skip the first 1MB of a file, using the skip option to read to the end of the file skipping the first 1MB.
Using the seek option you can write a to a specific place in your output file. Say you want to keep the first 1MB and over write the last 8MB.
You probably need to get some details about your file size to make sure you get the right amount of data in and out.
man ls
--block-size=SIZE
use SIZE-byte blocks. See SIZE format below
-s, --size
print the allocated size of each file, in blocks
SIZE may be (or may be an integer optionally followed by) one of fol‐
lowing: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T,
P, E, Z, Y.
|
||||
|
|