From owner-freebsd-questions Thu Mar 4 23:47:27 1999 Delivered-To: freebsd-questions@freebsd.org Received: from alpha.comkey.com.au (alpha.comkey.com.au [203.9.152.215]) by hub.freebsd.org (Postfix) with SMTP id 69E8D150F5 for ; Thu, 4 Mar 1999 23:47:21 -0800 (PST) (envelope-from gjb@comkey.com.au) Received: (qmail 14323 invoked by uid 1001); 5 Mar 1999 07:38:08 -0000 Message-ID: <19990305073808.14322.qmail@alpha.comkey.com.au> X-Posted-By: GBA-Post 1.04 06-Feb-1999 X-PGP-Fingerprint: 5A91 6942 8CEA 9DAB B95B C249 1CE1 493B 2B5A CE30 Date: Fri, 05 Mar 1999 17:38:08 +1000 From: Greg Black To: Ben Smithurst Cc: Keith Anderson , questions@FreeBSD.ORG Subject: Re: omething simple (sorry) References: <19990304191114.A11792@scientia.demon.co.uk> In-reply-to: <19990304191114.A11792@scientia.demon.co.uk> of Thu, 04 Mar 1999 19:11:14 GMT Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > in dos I would use copy *.txt *.old > > Cp and mv can't do this alone, since your shell will expand the wilcards > before they see them. And if you protect the wildcard characters, cp and > mv won't expand them at all. Try something like this, in /bin/sh and > friends: > > for i in *.txt; do mv $i $(basename $i .txt); done > > Replace "mv" with "cp" if you want to copy rather than just move/rename > the files. Close, but no cigar. It's not too hard to check your answers before offering them. To do what was asked, this should be: for i in *.txt; do mv $i $(basename $i .txt).old; done There is of course a nice little script that's been around the traps for years that would do this job with this syntax: mved =.txt =.old It also does the job for cp and ln, depending on which name it's called by. -- Greg Black To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message