Get the latest e-discovery and computer forensics news in one place.

Sign up for the monthly JD&A Newsletter today!






The 12 Days of dd: Day Nine | Print |  E-mail
Written by Jason Briody   
Friday, 02 January 2009 00:00

On the ninth day of dd, we perform file conversions with dd.

Ever wanted to convert the format or content of an entire file? Depending on the circumstances, dd might be able to help. There are a number of seldom-used conversion (“conv”) options that dd offers, including:

• Converting records to fixed or variable lengths (conv=block or conv=unblock)
• Changing the case of all ASCII alphabetic characters in an entire file (conv=lcase or conv=ucase)
• Converting a file from EBCDIC (a character encoding scheme used on older IBM mainframes and midrange computers) to ASCII and vice-versa (conv=ascii or conv=ebcdic)
• Swapping every pair of bytes, either to fix a file that’s had its bytes switched around inadvertently, or as a simple encryption method (conv=swab)

You can test out the functionality of dd’s conv very easily by creating a new text file (“myfile1”) in your present working directory, opening it, and typing:

i typed this in lowercase.

Save it, then do a quick conversion on the file to change the case of the characters by typing the following at a command line:

# dd if=myfile1 of=myfile2 conv=ucase

Hit enter, then open myfile2. It should read:

I TYPED THIS IN LOWERCASE.

dd successfully converted the lowercase ASCII alphabetic characters in myfile1 to uppercase in myfile2. Try out the other conv options and see what you come up with!