Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn
From: gwyn@brl-smoke.ARPA (Doug Gwyn )
Newsgroups: comp.unix.wizards
Subject: Re: globbing in the shell (Was Re: more rm insanity)
Message-ID: <6781@brl-smoke.ARPA>
Date: Thu, 3-Dec-87 01:59:01 EST
Article-I.D.: brl-smok.6781
Posted: Thu Dec  3 01:59:01 1987
Date-Received: Sun, 6-Dec-87 10:15:13 EST
References: <1257@boulder.Colorado.EDU> <6840002@hpcllmv.HP.COM>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) )
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 45

In article <12441@think.UUCP> barmar@sauron.UUCP (Barry Margolin) writes:
>For example, there's no way to write a version of the cp or mv commands
>that takes an alternating list of source and destination pathnames,

$ apply -2 cp src1 dst1 src2 dst2 src3 dst3

or

$ echo 'src1 dst1 src2 dst2 src3 dst3' | while read s d; do cp $s $d; done

>where the source pathnames are permitted to have wildcards.

If you allow this, then how do you ensure 1-1 correspondence
between sources and destinations?  Or are you assuming the
destinations must be directories?  If so, then a modification
of the second method will work, if the wildcard arguments are
quoted and "eval" is used to do the cp.

>You also can't do something like Multics's
>
>	rename foo.** foo.bar.==
>
>(the == is replaced by whatever the ** matched) without writing a
>complicated script that used grep and sed on the output of ls.

$ for i in foo.*; do mv $i `echo $i | sed 's/foo/&.bar/'`; done

Notice that with this approach I can perform types of renaming
that are well beyond the built-in ability of Multics's "rename".

If I had to do any of these operations very often, I would make
scripts or shell functions rather than type them in by hand
each time.

The advantage of the UNIX "toolkit" approach to such issues is
that the user of a command like "cp" is not limited to what the
command's designer was able to anticipate.  I actually do things
analogous to my last example routinely, interactively, in ways
that I am sure would never have been built into any utility
command.  I also encounter "integrated" utilities that attempt
to offer all the functionality everyone could ever want, and
somehow they usually don't seem to be able to do what I need.
The price paid for UNIX's flexibility is that one needs to learn
how to use the tools effectively.  But I would think that the
expert user would want to learn that anyway.