(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



dd

2003/11/03



The dd command without any options simply reads stdin and writes stdout; it's a copier like cat ("dd" stands for datadumper). If that were the end of it, there would be no reason for it to exist.

However, it can do much more, such as converting ASCII to EBCDIC and vice versa. The need for that has almost (but not quite) disappeared, yet dd still has use. It can block and unblock records (converting vast sequences of bytes to line oriented data and vice versa), programatically skip or seek past input or output (useful for reading or writing X bytes into a file), and more.

Given a file "t" containng "123456790",


 dd if=t bs=1 skip=3
 

produces "4567890", and

echo "abc" | dd of=t seek=3 count=2 bs=1 conv=notrunc
 

leaves "t" as "123ab67890".

If "t" is instead:

123467890
123467890
123467890
123467890
 

Then "dd if=t conv=block cbs=10 " will produce exactly 40 bytes of "1234567890123456789012345678901234567890". Given those 40 bytes, "dd if=u conv=unblock cbs=5" will give you back 8 lines:

12345
67890
12345
67890
12345
67890
12345
67890
 

At the end of any transfer, dd always reports the number of full and partial blocks it read and wrote. Given our same file "t"

echo "1234567890" > t
dd if=t ibs=3 obs=4 
1234567890
3+1 records in
2+1 records out
dd if=t ibs=3 obs=1
1234567890
3+1 records in
11+0 records out
 

See also Using unblock and block with dd to add linefeeds and white space padding.




Click here to add your comments

See also volcopy for a way to "dd" UNIX filesystems.

--BigDumbDinosaur



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!



 I sell and support
 Kerio Mail server




pavatar.jpg
More:
       - Shell


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress