From owner-freebsd-questions@FreeBSD.ORG Tue May 18 17:20:32 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 60DE816A4CE for ; Tue, 18 May 2004 17:20:32 -0700 (PDT) Received: from wonkity.com (wonkity.com [65.173.111.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 007B643D1F for ; Tue, 18 May 2004 17:20:32 -0700 (PDT) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.12.11/8.12.11) with ESMTP id i4J0KNIf080422; Tue, 18 May 2004 18:20:23 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.12.11/8.12.11/Submit) with ESMTP id i4J0KNw8080419; Tue, 18 May 2004 18:20:23 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Tue, 18 May 2004 18:20:23 -0600 (MDT) From: Warren Block To: Drew Tomlinson In-Reply-To: <40AA4977.9020304@mykitchentable.net> Message-ID: <20040518175629.C80176@wonkity.com> References: <200405181725.i4IHPXtT016748@beast.csl.sri.com> <40AA4977.9020304@mykitchentable.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Mike Hogsett cc: FreeBSD Questions Subject: Re: How To Copy A Group of Files To Different Name? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2004 00:20:32 -0000 On Tue, 18 May 2004, Drew Tomlinson wrote: > OK, thanks. I'm using tcsh but I think I figure out how to do it > following your example. So a "script" is the only way to do it in > *nix? Being born and raised on MS-DOS, I'm accustomed to the "copy bac* > bac*.old" syntax. It has to do with shell globbing. The bac* parameter is expanded to a list of all files matching that pattern, then fed to the command. So if you type 'cp bac* bac*.old' in a Unix shell and your directory has files bac1, bac2, bac3, and bac4, what it actually tries to execute is: cp bac1 bac2 bac3 bac4 Note that bac*.old didn't evaluate to anything: there aren't any files or directories that match that pattern. So cp gives an error-- it'll copy multiple files to a directory, but only if the last parameter is a directory. There are numerous recipes for doing the batch move-and-rename. The O'Reilly Unix Power Tools book (highly recommended) has a script that pipes the output of ls into sed, generating a bunch of individual mv commands. You can do the same thing with find, or Perl, or other things. -Warren Block * Rapid City, South Dakota USA