Date: Tue, 18 May 2004 18:20:23 -0600 (MDT) From: Warren Block <wblock@wonkity.com> To: Drew Tomlinson <drew@mykitchentable.net> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: How To Copy A Group of Files To Different Name? Message-ID: <20040518175629.C80176@wonkity.com> In-Reply-To: <40AA4977.9020304@mykitchentable.net> References: <200405181725.i4IHPXtT016748@beast.csl.sri.com> <40AA4977.9020304@mykitchentable.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040518175629.C80176>