[Chapter 35] 35.6 Low-Level File Butchery with dd
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:48:03Z

#

| Chapter 35 You Can't Quite Call This Editing |

## 35.6 Low-Level File Butchery with dd

Want to strip off some arbitrary number of characters from the front of a file?

dd provides an unexpectedly easy answer. Let's say you wanted to delete the first 100 characters in a file. Here's the command that will do the trick (assuming of course that you give dd a filename with the if= option or data from a pipe):

>     % dd bs=100 skip=1

Or you could try:

>     % dd bs=1 skip=100

dd normally reads and writes data in 512-byte blocks; the input block size can be changed with the ibs= option, and the output block size with obs=. Use bs= to set both. skip= sets the number of blocks to skip at the start of the file.

Why would you want to do this? Article 22.17 gives an interesting example when encrypting files. Article 20.6 explains using dd over a network with a tape drive. To convert files between ASCII and EBCDIC, see article 35.12. Article 35.13 shows even more uses for dd.

- TOR

35.5 Remove Mail/News Headers with behead |  | 35.7 offset: Indent Text