Linux dd 命令用于读取、转换并输出数据。

dd 可从标准输入或文件中读取数据,根据指定的格式来转换数据,再输出到文件、设备或标准输出。

参数说明(dd --help)Usage: dd [OPERAND]...

or: dd OPTION

Copy a file, converting and formatting according to the operands.

bs=BYTES read and write BYTES bytes at a time (also see ibs=,obs=)

cbs=BYTES convert BYTES bytes at a time

conv=CONVS convert the file as per the comma separated symbol list

count=N copy only N input blocks

ibs=BYTES read BYTES bytes at a time (default: 512)

if=FILE read from FILE instead of stdin

iflag=FLAGS read as per the comma separated symbol list

obs=BYTES write BYTES bytes at a time (default: 512)

of=FILE write to FILE instead of stdout

oflag=FLAGS write as per the comma separated symbol list

seek=BLOCKS skip BLOCKS obs-sized blocks at start of output

skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input

status=WHICH WHICH info to suppress outputting to stderr;

'noxfer' suppresses transfer stats, 'none' suppresses all

BLOCKS and BYTES may be followed by the following multiplicative suffixes:

c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M

GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Each CONV symbol may be:

ascii from EBCDIC to ASCII

ebcdic from ASCII to EBCDIC

ibm from ASCII to alternate EBCDIC

block pad newline-terminated records with spaces to cbs-size

unblock replace trailing spaces in cbs-size records with newline

lcase change upper case to lower case

nocreat do not create the output file

excl fail if the output file already exists

notrunc do not truncate the output file

ucase change lower case to upper case

sparse try to seek rather than write the output for NUL input blocks

swab swap every pair of input bytes

noerror continue after read errors

sync pad every input block with NULs to ibs-size; when used

with block or unblock, pad with spaces rather than NULs

fdatasync physically write output file data before finishing

fsync likewise, but also write metadata

Each FLAG symbol may be:

append append mode (makes sense only for output; conv=notrunc suggested)

direct use direct I/O for data

directory fail unless a directory

dsync use synchronized I/O for data

sync likewise, but also for metadata

fullblock accumulate full blocks of input (iflag only)

nonblock use non-blocking I/O

noatime do not update access time

noctty do not assign controlling terminal from file

nofollow do not follow symlinks

count_bytes treat 'count=N' as a byte count (iflag only)

Sending a USR1 signal to a running `dd' process makes it

print I/O statistics to standard error and then resume copying.

$ dd if=/dev/zero of=/dev/null& pid=$!

$ kill -USR1 $pid; sleep 1; kill $pid

18335302+0 records in

18335302+0 records out

9387674624 bytes (9.4 GB) copied, 34.6279 seconds, 271 MB/s

需重点查看参数:if, of, bs, skip, count

示例

源数据准备cat>dd_in.txt<

a

b

c

d

EOF

二分查看,前半部分数据dd bs=1 count=4 if=dd_in.txt

a

b

4+0 records in

4+0 records out

4 bytes (4 B) copied, 9.903e-05 s, 40.4 kB/s

二分匹配数据dd bs=1 count=4 if=dd_in.txt | grep b # 能匹配到

dd bs=1 count=4 if=dd_in.txt | grep c # 不能匹配到

二分查看,后半部分数据dd bs=1 skip=4 count=4 if=dd_in.txt

c

d

4+0 records in

4+0 records out

4 bytes (4 B) copied, 0.00013476 s, 29.7 kB/s

二分匹配数据dd bs=1 skip=4 count=4 if=dd_in.txt | grep b # 不能匹配到

dd bs=1 skip=4 count=4 if=dd_in.txt | grep c # 能匹配到

示例解释

dd bs=1 count=4 if=dd_in.txt

bs=1 设置每次查找块大小为1字节(这里数据小用1字节方便说明。在大文件的情况下,可以用 1024 这样 1KB 或更大的值加快扫描速度)

count=4 取4个块区,这个值需要配合文件大小计算出,前半部分。

以上就实现,文件二分查找前半部分,配合 grep 即可进行查找操作。

文件后半部分的查找需要配合 skip,跳过块区。

linux dd 大文件下载,Linux dd+grep 大文件二分查找相关推荐

  1. Linux工作笔记-使用find和grep检索文件或子文件中是否包含指定字符串

    目录 概念 演示 概念 Linux中有一个find命令,可以用于查找文件名,使用grep命令,可以用于检索文件夹中的字符串,这两个命令配合起来,可以实现强大的功能. 其中grep中有一个 -i选项,是 ...

  2. linux安装库文件下载,Linux下的Curses库的下载与安装

    curses库是可以在Linux 终端中写出字符用户界面的一个库,现在较新的版本应该是ncurses库,现在已经很少有人再去使用他了,所以想拥有这个库并且在linux下写出自己用户界面的可以参考一下本 ...

  3. linux的头文件下载,Linux内核头文件(linux headers)

    更新 Linux 内核头文件(linux headers) 三 8th, 2013 2,474 views | 发表评论 | Trackback 一般来说,如果不是自己编译 kernel,那么更新头文 ...

  4. linux开机脚本文件下载,linux 开机启动脚本

    sh /etc/init.d/inotifywaitreloadnginx.sh 方法一 1.赋予脚本可执行权限(/opt/script/autostart.sh是你的脚本路径) chmod +x / ...

  5. Linux开发入门笔记——Linux使用基础

    一直对Linux十分向往,因为听说大佬们都是使用Linux来进行开发的.使用Linux是区别会计算机和普通人的一个关键的依据.所以当我准备开始学Linux的时候就有种升级技能,获得成就的感觉. 当然现 ...

  6. Linux系统如何测试电脑性能,如何使用DD命令测试Linux磁盘的性能?

    Linux系统下DD命令是常用的命令之一,同时DD命令的使用范围也比较广泛.除了已知的可以用DD命令来复制文件外,还可以用DD命令来测试磁盘的性能.那么如何使用DD命令测试Linux磁盘的性能? 下面 ...

  7. linux dd入门,Linux基础知识:Linux中DD命令详解

    1.dd命令简介 功能:把指定的输入文件拷贝到指定的输出文件中,并且在拷贝过程中可以进行格式转换.可以用该命令实现DOS下的diskcopy命令的作用.先用dd命令把软盘上的数据写成硬盘的一个寄存文件 ...

  8. dd命令安装Linux

    面对大批量服务器的安装,人们往往热衷于选择"无人值守安装"的方式,而此方式需要对服务器进行过多的配置,并不适合初学者. 无人值守安装(Kickstart),又称全自动安装,其工作原 ...

  9. Linux centOS系统备份还原(dd+rsync方式)

    Linux系统备份对一些关键的单点业务是非常重要的,下面将说说采用简单的工具进行备份,实用派. 一.rsync备份系统 rsync -PpavAHX 备份源目录 备份到位置 rsync -PpavAH ...

最新文章

  1. resin-pro-4.0.34 服務器在windows环境下的配置
  2. 滑动定位的三种方法,以及热启动(五)
  3. 分布式系统的面试题14
  4. linux date使用方法,linux命令详解date使用方法(计算母亲节和父亲节日期脚本示例)...
  5. CYQ.Data V5 分布式自动化缓存设计介绍(二)
  6. WebService大讲堂之Axis2(2):复合类型数据的传递
  7. 如何正确访问Redis中的海量数据?服务才不会挂掉!
  8. mybatisplus执行sql语句_一条更新的SQL语句是如何执行的?
  9. 在main函数前后执行的函数之 C语言
  10. 程序员最讨厌的100件事,瞬间笑喷了,哈哈~~
  11. libevent的线程优雅的退出方式
  12. emule学习与分析二 上 建立连接过程分析
  13. GPU图形绘制管线简介
  14. 计算机编号、硬盘序列号和Mac地址查询方法
  15. 购买的域名设置域名解析
  16. 智慧水务大数据平台-智慧水务建设方案
  17. 毕业薪酬行业第一?计算机+金融交叉学科真香
  18. 7-7 社交集群 (30 分) (集合数组的方法)
  19. kerberos+druid+phoenix
  20. Win10的IE以及其他浏览器无法使用的解决方法

热门文章

  1. 掌握这些技巧助你轻松绘制程序流程图
  2. 关于http://127.0.0.1:4723/wd/hub的解释
  3. MySQL安装失败问题汇总
  4. 下面我将随机抽取一名幸运女生,XXXXX
  5. DDD 领域驱动设计-如何 DDD?
  6. 完毕port(CompletionPort)具体解释 - 手把手教你玩转网络编程系列之三
  7. Nagios+Centreon+Nrpe集成(二)
  8. 新浪微博oauth2.0弹出验证dialog中输入框被输入法覆盖的解决办法
  9. Lazy loading
  10. MSSQL2005 手工盲注 总结