Article Title: Compare the speed of copying files between GUNcp and tar. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The two commands are not familiar to anyone. But what is the faster processing speed? I have discussed CU and other forums. I have done some experiments. .. Practice, CP is faster.
Cao wrote a tar quick file copy tip.
# Cd/data/test1 # Tar-cf-. | (cd/data/test2; tar-xvpf -) |
My simple practices:
1. Relative Path VS absolute path
[Code] # Time tar-cf-. | (cd/tmp/test2/; tar-xvpf -) ./ ./Linuxtone_2009_04_09.log.gz ./Linuxtone_2009_04_10.log.gz ./Linuxtone_2009_04_11.log.gz ./Linuxtone_2009_04_12.log
Real 0m3. 150 s User 0m0. 108 s Sys 0m1. 754 s [/Code]
[Code] Relative Path # Time cp-r * ../test2/
Real 0m1. 167 s User 0m0. 053 s Sys 0m1. 065 s [/Code]
Cp is 1.983 s faster than tar
[Code] Absolute path # Time cp-r */tmp/test2/
Real 0m1. 170 s User 0m0. 070 s Sys 0m1. 056 s [/Code] Cp is 1.98 s faster than tar |
Ii. File Attributes
Some people say that cp cannot be copied together with the attributes of files and folders. Better than tar. In fact, man cp can see
-P same as -- preserve = mode, ownership, timestamps -- Preserve [= ATTR_LIST] Preserve the specified attributes (default: mode, ownership, timestamps) and security contexts, if possi- Ble additional attributes: links, all
|
Because the directory contains files and folders, you can use
-A, -- archive Same as-dpR |
The test speed is not much different from the above speed. Cp is still faster than tar
3. If the cp does not see the progress, it can be as follows:
Cd/mnt/cdrom For I in * Do Cp $ I target directory Echo $ I is OK .... Done |