#!/usr/bin/env perl # # mvto - mv to the first argument # # $Id$ # Usage: ... | xargs mvto $dir # see also ./cpto # I wrote ./argswapping for this but it requires -n1 on xargs # move the last argument to the first non-option, then call mv # GNU mv allows options to be anywhere, I'll assume this is true # # for all mvs we meet, so I'll just reorder them # my @opt = grep { /^-/ } @ARGV; my @arg = grep { !/^-/ } @ARGV; if ( @arg < 2 ) { die "fatal error: supply at least two arguments\n"; } else { my @cmd = ( 'mv', @opt, @arg[ 1 .. $#arg, 0 ] ); warn join( ' ', @cmd ), "\n"; exec(@cmd); }