Want to strip off some arbitrary number of characters from the front of a file?
Go to http://examples.oreilly.com/upt3 for more information on: dd
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? Section 21.9 gives an interesting example of reading text from standard input and writing it to a series of smaller files. Section 21.13 shows even more uses for dd.
-- TOR
Copyright © 2003 O'Reilly & Associates. All rights reserved.