Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Arglist too long...mv'ed crazy



On Apr 1,  4:10am, meino.cramer@xxxxxx wrote:
}
}  zargs -- ../../cur/* -- mv ???????????
} 
}  Due to this I have two questions:
}  How can I cope the "reversed argument" problem with zargs in general?

You can either put a wrapper around the command like

    function mvto { local target=$1; shift; mv $* $target }
    zargs -- ../../cur/* -- mvto /back/up/folder

or (in the specific case of "mv") you can use

    zargs -- ../../cur/* -- mv --target-directory=/back/up/folder

(which as nearly as I can tell exists solely for compatibility
with xargs and its ilk)

or you can use the --replace option to zargs

    zargs --replace -- ../../cur/* -- mv {} /back/up/folder

The wrapper function could be generalized:

    function first2last { local c=$1 d=$2; shift 2; $c $* $d }
    zargs -- ../../cur/* -- first2last mv /back/up/folder

}  How can I handle the "arglist too long" problem with mv?

You could try using zsh's built-in "mv"

    zmodload -i zsh/files
    mv ../../cur* /back/up/folder

but that won't work if /back/up/folder is on a different filesystem
than ../../cur, because the builtin mv won't fall back on cp+rm.

You might also consider 

    tar --create --remove-files --directory=../../cur --file=- . |
	tar --extract --directory=/back/up/folder --file=-

However, that's a little dangerous because the --remove-files might
take effect even if the --extract fails for some reason.



Messages sorted by: Reverse Date, Date, Thread, Author