Timeline for How do I trim bytes from the beginning and end of a file?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 24, 2017 at 21:25 | comment | added | ilkkachu |
with bs=1 dd makes two system calls for each byte, that's horribly slow. GNU dd has the count_bytes and skip_bytes that can help, do something like dd bs=8192 iflag=count_bytes,skip_bytes skip=25 count=73 < infile > outfile
|
|
May 24, 2017 at 21:22 | comment | added | Ravexina | Yeah, however bs is defined 1 in your command :-) so in this case it will work... | |
May 24, 2017 at 21:19 | comment | added | jc__ | Remember that skip and count are blocks not bytes. Pick the largest multiple for the block size. The closer the block size is to the HD buffer size the more efficient and faster the command is. | |
May 24, 2017 at 21:06 | comment | added | Ravexina |
it took 0m8.319s for a 1.3 MB file, For the count he can use something like $(( stat -c %s test` - 5 ))` I guess.
|
|
May 24, 2017 at 21:01 | comment | added | jc__ | Too slow? Only if the file is very large like many GB. Then you could adjust the block size. | |
May 24, 2017 at 21:00 | comment | added | Ravexina | isn't too slow? | |
May 24, 2017 at 20:58 | history | answered | jc__ | CC BY-SA 3.0 |