Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!rutgers!njin!princeton!njsmu!mccc!jonlab!jon From: jon@jonlab.UUCP (Jon H. LaBadie) Newsgroups: comp.unix.questions Subject: Re: simple question about mv Summary: too many forks Message-ID: <626@jonlab.UUCP> Date: 1 Feb 89 03:23:51 GMT References: <18231@adm.BRL.MIL> <4093@omepd.UUCP> Organization: 4455 Province Line Rd., Princeton, NJ 08540 Lines: 33 In article <4093@omepd.UUCP>, merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) writes: In article <18231@adm.BRL.MIL>, moss@BRL (VLD/VMB) writes: | Well, this should work under a Bourne shell: | $ for i in *.flip | > do mv $i `basename $i .flip` .flop | > done | $ Randal and others (this is not intended to pick on Randal's suggestion) have proposed work-arounds to UNIX's command line interpreters (or to mv's) deficiency in wild card matching. Each have proposed a separate mv command for each file. This is unfortunate, but probably necessary. However, each suggestion has also necessitated a separate process such as cut, sed, or in Randal's case, basename, for each file to be moved. An alternative, is one command line to create a list of "root names" and loop through them. For a large number of files, this could greatly enhance the efficiency of the processing. Ksh users could improve upon this even more using the special substitution facilities of that shell. for root in `ls *.flip | cut -d. -f1` do mv ${root}.flip ${root}.flop done Potential problems still exist if a) two "."s are int the file names, or b) not ".flip" files exist. Isn't UNIX great? :-) for guru's! ;-) -- Jon LaBadie {att, ulysses, princeton, bcr}!jonlab!jon