Tag Info

New answers tagged

2

Not cp directly, that's well beyond its abilities. But you can arrange to call cp on the files in the right order. Zsh conveniently allows sorting files by size with a glob qualifier. Here's a zsh snippet which copies files in increasing order of size from under /path/to/source-directory to under /path/to/destination-directory. cd /path/to/source-directory ...


1

another option would be to use cp with the output from du: oldIFS=$IFS IFS='' for i in $(du -sk *mpg | sort -n | cut -f 2) do cp $i destination done IFS=$oldIFS This could still be done on one line, but I split it so you can read it


8

This does the whole job in one go - in all child directories, all in a single stream without any filename problems. It'll copy from smallest to largest every file you have. You will need to mkdir ${DESTINATION} if it doesn't already exist. find . ! -type d -print0 | du -b0 --files0-from=/dev/stdin | sort -zk1,1n | sed -zn 's/^[^0-9]*[0-9]*[^.]*//p' | tar ...


2

Here is a quick and dirty method using rsync. For this example I am considering anything under 10 MB to be "small". First transfer just the small files: rsync -a --max-size=10m srcdir dstdir Then transfer the remaining files. The previously transferred small files will not be re-copied unless they were modified. rsync -a srcdir dstdir From man 1 rsync ...


1

I don't think there is any way to get cp -r to do this directly. Since it may be an indeterminate period of time before you get a wizardly find/awk solution, here's a quick perl script: #!/usr/bin/perl use strict; use warnings FATAL => qw(all); use File::Find; use File::Basename; die "No (valid) source directory path given.\n" if (!$ARGV[0] || !-d ...


3

It always annoys how CentOS/RHEL, by default, on a large hard disk, create a fairly small / partition and a really huge /home partition. This is why, when install CentOS, I always manually partition, and never use LVM (which, I have heard, also reduces performance). LVM makes sense when you want to stream a partition across multiple hard disks, but not as ...



Top 50 recent answers are included