dd命令的用法

前端之家收集整理的这篇文章主要介绍了dd命令的用法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

脚本会根据剩余空间的大小来计算一个参数,剩余空间很多时,参数值为A;剩余空间较少时,参数值为剩余空间大小的函数;剩余空间有1G时,总是值A;为了验证参数值为剩余空间大小的函数的情况,需要使获得的剩余空间的值小一些,此时,我们可以使用dd命令来创建一个大小为9000M的空白文件,从而使得剩余空间为1024M这样,然后继续测试。

命令使用示例:

[root@db22 ~]# df -m /home
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda3 18043 13072 4055 77% /
[root@db22 ~]# dd if=/dev/zero of=/tmp/holdspace.fil bs=1M count=3000
3000+0 records in
3000+0 records out
3145728000 bytes (3.1 GB) copied,8.92085 s,353 MB/s
[root@db22 ~]# df -m /home
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda3 18043 16072 1055 94% /

上面的示例命令可以看到可用空间从4055M变成了1055M,是因为我们创建了一个3000M的空白文件holdspace.fil。
参数说明:
- if:[input file]输入文件
- of:[output file] 输出文件
- bs:[bytes]字节
- count:数量

通过man来看一下dd命令的用法

NAME
       dd - convert and copy a file

SYNOPSIS
       dd [OPERAND]...
       dd OPTION

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

       bs=BYTES
              read and write BYTES bytes at a time (also see ibs=,obs=)
              每一次读写BYTES个字节

       cbs=BYTES
              convert BYTES bytes at a time
              每一次转换BYTES个字节

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

       count=BLOCKS
              copy only BLOCKS input blocks
              只拷贝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=noxfer
              suppress transfer statistics

       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
       ...  ...
原文链接:https://www.f2er.com/bash/390027.html

猜你在找的Bash相关文章