我只想从rsync -i
提取:
- 文件名
- 大小
- 速度
- 持续时间
我正在使用此命令:
rsync -e ssh --rsync-path="sudo rsync" -azih --progress --delete-after
--delete-excluded --exclude=".*" --exclude=".*/" "$local_dir" "$host":"$remote_path" | egrep -A1 '<'
已经为我输出了这样的东西:
<f.stpog... tools/file.sh
22,561 100% 20.85MB/s 0:00:00 (xfr#1, to-chk=0/6)
因此,这个想法是获得这样的一行输出:
tools/file.sh 22,561 100% 20.85MB/s 0:00:00
有什么想法?
您最好的选择可能是使用xargs
和cut
的组合。
rsync -e ssh --rsync-path="sudo rsync" -azih --progress --delete-after --delete-excluded --exclude=".*" --exclude=".*/" "$local_dir" "$host":"$remote_path" | egrep -A1 '<' | xargs -n8 | cut -d' ' -f2-6
xargs -n8
将您的输出将您的输出分为每行8个项目(假设这是已知且一致的(,并且cut -d' ' -f2-6
将打印第二到第六个字符。在带有输出的测试文件上,这可以工作。
$ cat testrsync
<f.stpog... tools/file1.sh
22,561 100% 20.85MB/s 0:00:00 (xfr#1, to-chk=0/6)
<f.stpog... tools/file2.sh
21,230 100% 21.22MB/s 0:00:00 (xfr#1, to-chk=0/6)
<f.stpog... tools/file3.sh
43,340 100% 20.34MB/s 0:00:00 (xfr#1, to-chk=0/6)
$ cat testrsync | xargs -n8 | cut -d' ' -f2-6
tools/file1.sh 22,561 100% 20.85MB/s 0:00:00
tools/file2.sh 21,230 100% 21.22MB/s 0:00:00
tools/file3.sh 43,340 100% 20.34MB/s 0:00:00