simple question about mv
David Sherman
dave at lsuc.uucp
Sun Jan 29 11:35:13 AEST 1989
In article <18230 at adm.BRL.MIL> moss at BRL.MIL (VLD/VMB) writes:
|< I know this is simple, but then again, so am I. What if I want to mv a bunch
|< of files with the same suffix to another suffix. The following does not
|< work
|<
|< mv *.flip *.flop
|Well, this should work under a Bourne shell:
|$ for i in *.flip
|> do mv $i `basename $i .flip` .flop
|> done
|$
Moss's suggestion is the best, once you know what you're
doing. For people who are a little scared of such magic
before they're fully conversant with sh, it's more comforting
to edit a script which has the mv's explicitly. Just use good old ed:
$ ls *.flip > junk
$ ed junk
g/.flip/s///
g/.*/s//mv &.flip &.flop/p
w
q
$ sh -x junk
(Personally, I used qed and would say
$ qed
<ls *.flip
,s/\(.*\).flip$/mv & \1.flop
>sh -x
Q
but not that many people have qed.)
The point is that you can see what the mv commands look like,
in the editor, before you shovel them at the shell. It's reassuring.
Note also the sh -x, which lets you watch the commands as they run.
David Sherman
Toronto
--
Moderator, mail.yiddish
{ uunet!attcan att pyramid!utai utzoo } !lsuc!dave
More information about the Comp.unix.wizards
mailing list