当你使用
rsync -avzh --stats --out-format="%t %f %b"
它以字节为单位输出手册页中的以下内容
In addition, one or more apostrophes may be specified prior to a numerical escape to indicate that the numerical value should be made more human-readable. The 3 supported levels are the same as for the --human-readable command-line option, though the default is for human- readability to be off. Each added apostrophe increases the level (eg "%''l %'b %f").
我的问题是我有多less撇号之间的%b之间将其从字节更改为兆字节?
只要我添加一个撇号这是什么发生在日志
rsync -av --out-format="%t %f %'b" 2016/10/29 01:00:22 home/data/Clients/P/Power Solutions CC/2017/Sales Report %'b
我已经键入命令,不复制html,但似乎无法得到正确显示日志
阅读手册页的人--human-readable部分可以--human-readable
-h, – 人可读
以更易读的格式输出数字。 这使大数字输出使用较大的单位,与K,M或G后缀。 如果这个选项被指定一次,这些单位是K(1000),M(1000 * 1000)和G(1000 * 1000 * 1000); 如果重复选项,单位是1024而不是1000的幂。
但是,这并不是特别清楚,所以让我们把科学方法带到实验中来。 我们将使用一些文件,并使用rsync来复制它们。 我们将记下它为每个不同的命令行选项生成的相关输出。
以下是我们将执行实验的文件。
ls -lh test.* -rw-rw-r--. 1 iain iain 40435 Oct 31 09:08 test.png -rw-rw-r--. 1 iain iain 853483520 Oct 31 09:08 test.tar
那么我们将使用rsync来复制它们。 请注意,我们每次都删除目标文件,但不显示任何工作。
testing1
rsync -av --out-format="%t %f %b" ./test.* /tmp/ sending incremental file list 2016/10/31 09:10:42 test.png 40482 2016/10/31 09:10:45 test.tar 853587747
所以%b给出了一个简单的字节值
testing2
rsync -av --out-format="%t %f %'b" ./test.tar /tmp/ sending incremental file list 2016/10/31 09:11:25 test.png 40,482 2016/10/31 09:11:28 test.tar 853,587,747
%'b给出一个字节值,
testing3
rsync -av --out-format="%t %f %''b" ./test.* /tmp/ sending incremental file list 2016/10/31 09:12:29 test.png 40.48K 2016/10/31 09:12:32 test.tar 853.59M
%''b给出了适当的KB / MB(和GB)大小
最后
testing4
rsync -av --out-format="%t %f %'''b" ./test* /tmp/ sending incremental file list 2016/10/31 09:17:49 test.png 39.53K 2016/10/31 09:17:52 test.tar 814.04M
%'''b给予KiB / MiB等的值也适当缩放。
结论
如果你想以MB为单位expression一切,那么当输出按照适当的文件大小缩放到K / M / G等时,你不能做你想要的。
如果你想K / M / G等B然后'' ,如果你想KiB / MiB / GiB等,那么'''就是你想要的。
所以,你的问题的答案是,这取决于你的意思
将其从字节更改为兆字节