Re: How To Copy A Group of Files To Different Name?
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. On the command line (tcsh): ls bac* bac1 bac2 bac3 foreach file ( bac* ) foreach? cp -p $file $file.old foreach? end ls bac* bac1 bac1.old bac2 bac2.old bac3 bac3.old cheers, Ruben ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
How To Copy A Group of Files To Different Name?
How can I copy a group of files to a different name. I want to copy all files starting with 'bacula*' to 'bacula*.old'. So I have these four files: blacklamb# ll bac* -r--r--r-- 1 root wheel 949 Apr 22 09:13 bacula-barcodes -rw-r- 1 root wheel 5792 May 17 16:52 bacula-dir.conf -rw-r- 1 root wheel 763 Apr 22 09:13 bacula-fd.conf -rw-r- 1 root wheel 1909 May 17 16:31 bacula-sd.conf I want to have copies of these files with '.old' appended to their names. I've tried 'cp -pv bac* bac*.old' but cp complains. Because it's only 4 files, I'll do each one independently but I'd like to know how to do this right for future reference. Thanks, Drew -- Visit The Alchemist's Warehouse Magic Tricks, DVDs, Videos, Books, More! http://www.alchemistswarehouse.com ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How To Copy A Group of Files To Different Name?
How can I copy a group of files to a different name. I want to copy all files starting with 'bacula*' to 'bacula*.old'. So I have these four files: blacklamb# ll bac* -r--r--r-- 1 root wheel 949 Apr 22 09:13 bacula-barcodes -rw-r- 1 root wheel 5792 May 17 16:52 bacula-dir.conf -rw-r- 1 root wheel 763 Apr 22 09:13 bacula-fd.conf -rw-r- 1 root wheel 1909 May 17 16:31 bacula-sd.conf I want to have copies of these files with '.old' appended to their names. I've tried 'cp -pv bac* bac*.old' but cp complains. Because it's only 4 files, I'll do each one independently but I'd like to know how to do this right for future reference. Well it may not be right, but there is more than one way to skin a cat. if using bash as your shell you could do for b in * do mv $b ${b}.old done ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How To Copy A Group of Files To Different Name?
On 5/18/2004 10:25 AM Mike Hogsett wrote: How can I copy a group of files to a different name. I want to copy all files starting with 'bacula*' to 'bacula*.old'. So I have these four files: blacklamb# ll bac* -r--r--r-- 1 root wheel 949 Apr 22 09:13 bacula-barcodes -rw-r- 1 root wheel 5792 May 17 16:52 bacula-dir.conf -rw-r- 1 root wheel 763 Apr 22 09:13 bacula-fd.conf -rw-r- 1 root wheel 1909 May 17 16:31 bacula-sd.conf I want to have copies of these files with '.old' appended to their names. I've tried 'cp -pv bac* bac*.old' but cp complains. Because it's only 4 files, I'll do each one independently but I'd like to know how to do this right for future reference. Well it may not be right, but there is more than one way to skin a cat. if using bash as your shell you could do for b in * do mv $b ${b}.old done 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. Thanks, Drew -- Visit The Alchemist's Warehouse Magic Tricks, DVDs, Videos, Books, More! http://www.alchemistswarehouse.com ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How To Copy A Group of Files To Different Name?
Drew Tomlinson wrote: How can I copy a group of files to a different name. I want to copy all files starting with 'bacula*' to 'bacula*.old'. So I have these four files: blacklamb# ll bac* -r--r--r-- 1 root wheel 949 Apr 22 09:13 bacula-barcodes -rw-r- 1 root wheel 5792 May 17 16:52 bacula-dir.conf -rw-r- 1 root wheel 763 Apr 22 09:13 bacula-fd.conf -rw-r- 1 root wheel 1909 May 17 16:31 bacula-sd.conf I want to have copies of these files with '.old' appended to their names. I've tried 'cp -pv bac* bac*.old' but cp complains. Because it's only 4 files, I'll do each one independently but I'd like to know how to do this right for future reference. You may want to take a look at the utility 'mmv' in the ports tree ('ports/misc/mmv' in CVS). For copying you would use the 'mcp' variant: mcp -v 'bacula*' 'bacula=1.old' It automatically preserves permissions and modification time. For a test run in order to verify in advance what would happen, use the '-n' option. Great tool IMHO. Uwe -- Uwe Doering | EscapeBox - Managed On-Demand UNIX Servers [EMAIL PROTECTED] | http://www.escapebox.net ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How To Copy A Group of Files To Different Name?
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 ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: How To Copy A Group of Files To Different Name?
On Tue, 18 May 2004, Drew Tomlinson wrote: How can I copy a group of files to a different name. I want to copy all files starting with 'bacula*' to 'bacula*.old'. So I have these four files: blacklamb# ll bac* -r--r--r-- 1 root wheel 949 Apr 22 09:13 bacula-barcodes -rw-r- 1 root wheel 5792 May 17 16:52 bacula-dir.conf -rw-r- 1 root wheel 763 Apr 22 09:13 bacula-fd.conf -rw-r- 1 root wheel 1909 May 17 16:31 bacula-sd.conf I want to have copies of these files with '.old' appended to their names. I've tried 'cp -pv bac* bac*.old' but cp complains. Because it's only 4 files, I'll do each one independently but I'd like to know how to do this right for future reference. Thanks, Drew Take a look at Krename. Oliver -- heit bin e ned munta wuan wäu ma r unsa bendlua schdeeblim is ... ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]