Date: Fri, 05 Mar 1999 17:38:08 +1000 From: Greg Black <gjb@comkey.com.au> To: Ben Smithurst <ben@scientia.demon.co.uk> Cc: Keith Anderson <keith@apcs.com.au>, questions@FreeBSD.ORG Subject: Re: omething simple (sorry) Message-ID: <19990305073808.14322.qmail@alpha.comkey.com.au> In-Reply-To: <19990304191114.A11792@scientia.demon.co.uk> of Thu, 04 Mar 1999 19:11:14 GMT References: <XFMail.990304231927.keith@apcs.com.au> <19990304191114.A11792@scientia.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
> > 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 <gjb@acm.org>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990305073808.14322.qmail>
