Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Apr 2004 17:36:59 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Peter Risdon <peter@circlesquared.com>
Cc:        FreeBSD Question List <freebsd-questions@freebsd.org>
Subject:   Re: Pipes and commands that require two arguments
Message-ID:  <20040408163658.GC26470@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <40757879.1010307@circlesquared.com>
References:  <40757879.1010307@circlesquared.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--i7F3eY7HS/tUJxUd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Apr 08, 2004 at 05:06:17PM +0100, Peter Risdon wrote:

> I want to redirect the output of a command to mv(1) as the source file,=
=20
> and specify somehow a destination directory. Basically, I have to move=20
> several thousand files whose names match a number of patterns to a=20
> single directory.
>=20
> Any suggestions will be gratefully received.

There's several ways of doing this.  Assuming you've got a command
"listfiles" which returns the list of files you want moved from the
current directory:

    % mv `listfiles` /destination/directory/

If the number of files to move is larger than the maximum number of
command linearguments:

    #!/bin/sh

    for f in `listfiles` ; do
        mv $f /destination/directory/
    done

or you can use xargs(1):

    listfiles | xargs -J % mv % /destination/directory/


	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--i7F3eY7HS/tUJxUd
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAdX+qdtESqEQa7a0RAjGlAJ43F4X1kk3W2EXaJenQ7/9txQ0WiQCffCrB
uAWOr0H+FV6l67VR8GQmXOo=
=3cLf
-----END PGP SIGNATURE-----

--i7F3eY7HS/tUJxUd--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040408163658.GC26470>