godd
A Go implementation of the dd command-line utility for file copying and conversion.
Usage
godd [OPERAND]...
Operands
| Operand |
Description |
if=FILE |
Read from FILE, URL, or - (default: stdin) |
of=FILE |
Write to FILE (default: stdout) |
bs=BYTES |
Read and write up to BYTES bytes at a time |
ibs=BYTES |
Read up to BYTES bytes at a time (default: 512) |
obs=BYTES |
Write BYTES bytes at a time (default: 512) |
cbs=BYTES |
Convert BYTES bytes at a time |
count=N |
Copy only N input blocks |
skip=N |
Skip N ibs-sized input blocks |
seek=N |
Skip N obs-sized output blocks |
conv=CONVS |
Comma-separated list of conversions |
iflag=FLAGS |
Comma-separated list of input flags |
oflag=FLAGS |
Comma-separated list of output flags |
status=LEVEL |
Status output level |
Conversions
| Symbol |
Description |
lcase |
Convert uppercase to lowercase |
ucase |
Convert lowercase to uppercase |
ascii |
Convert from EBCDIC to ASCII |
ebcdic |
Convert from ASCII to EBCDIC |
ibm |
Convert from ASCII to alternate EBCDIC |
block |
Pad newline-terminated records to cbs size |
unblock |
Replace trailing spaces with newlines |
swab |
Swap every pair of bytes |
sparse |
Seek rather than write all-NUL output blocks |
sync |
Pad incomplete input blocks to ibs size |
excl |
Fail if output file exists |
nocreat |
Do not create output file |
notrunc |
Do not truncate output file |
noerror |
Continue after read errors |
fdatasync |
Sync data before finishing |
fsync |
Sync data and metadata before finishing |
Input Flags (iflag)
| Symbol |
Description |
fullblock |
Accumulate full ibs blocks before writing |
nonblock |
Use non-blocking I/O |
noatime |
Do not update access time |
nofollow |
Do not follow symlinks |
direct |
Use direct I/O (Linux) |
directory |
Fail unless file is a directory |
dsync |
Synchronized I/O for data |
sync |
Synchronized I/O for data and metadata |
nocache |
Drop file system cache after read (Linux) |
noctty |
Do not assign controlling terminal |
Output Flags (oflag)
| Symbol |
Description |
append |
Append mode |
direct |
Use direct I/O (Linux) |
directory |
Fail unless file is a directory |
dsync |
Synchronized I/O for data |
sync |
Synchronized I/O for data and metadata |
nonblock |
Use non-blocking I/O |
noatime |
Do not update access time |
nocache |
Drop file system cache after write (Linux) |
noctty |
Do not assign controlling terminal |
nofollow |
Do not follow symlinks |
Numeric Suffixes
Suffixes can be appended to numeric operands (bs, ibs, obs, cbs, count, skip, seek):
| Suffix |
Multiplier |
Example |
c |
1 |
bs=1c = 1 |
w |
2 |
bs=2w = 4 |
b |
512 |
bs=4b = 2048 |
B |
1 |
bs=1B = 1 |
kB |
1000 |
bs=1kB = 1000 |
K |
1024 |
bs=1K = 1024 |
MB |
1000^2 |
bs=1MB = 1000000 |
M |
1024^2 |
bs=1M = 1048576 |
GB |
1000^3 |
bs=1GB = 1000000000 |
G |
1024^3 |
bs=1G = 1073741824 |
TB |
1000^4 |
bs=1TB = 1000000000000 |
T |
1024^4 |
bs=1T = 1099511627776 |
PB |
1000^5 |
|
P |
1024^5 |
|
EB |
1000^6 |
|
E |
1024^6 |
|
Status Levels
| Level |
Description |
| (default) |
Print final transfer statistics |
none |
Suppress all non-error output |
noxfer |
Suppress final transfer statistics |
progress |
Show periodic progress statistics |
bar |
Colorful progress bar with braille chars, percentage, throughput, ETA |
Examples
# Copy a file
godd if=input.txt of=output.txt
# Convert to uppercase
godd if=input.txt of=output.txt conv=ucase
# Copy with progress
godd if=/dev/zero of=/tmp/out bs=1M count=100 status=progress
# Create a 1GB sparse file
godd if=/dev/zero of=sparse.img bs=1M count=0 seek=1024
# Read from stdin, write to stdout
cat input.txt | godd conv=lcase
# Use EBCDIC conversion
godd if=ebcdic.dat of=ascii.txt conv=ascii
# Stream an HTTP URL directly
godd if=https://example.com/image.iso of=image.iso bs=1M status=bar
if= accepts http:// and https:// URLs. The response body is
streamed directly. Content-Length is used for progress bar when
available. Combine with status=bar for live download progress.
## Benchmarks
`make bench` runs godd against system `dd` across several workloads.
Results on Linux 6.x, AMD Ryzen 7, NVMe SSD:
| Workload | `dd` | `godd` | Ratio |
|----------|------|--------|-------|
| 1M blocks, 1G total | 839 MB/s | 933 MB/s | **1.11x** |
| 64K blocks, 1G total | 1.6 GB/s | 1.5 GB/s | 0.94x |
| 512b blocks, 64M total | 346 MB/s | 275 MB/s | 0.79x |
| conv=lcase, 64M | 492 MB/s | 390 MB/s | 0.79x |
godd is competitive with GNU dd for bulk I/O and often faster with
larger block sizes. Small-block and conversion-heavy workloads favor
dd's C implementation, as expected.