Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-lcc!lll-winken!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: simple question about mv Message-ID: <940@philmds.UUCP> Date: 29 Jan 89 12:49:28 GMT References: <18216@adm.BRL.MIL> <7558@chinet.chi.il.us> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 55 In article <7558@chinet.chi.il.us> les@chinet.chi.il.us (Leslie Mikesell) writes: |In article <18216@adm.BRL.MIL> DEG41560@ua1vm.ua.edu (Rob Smith) writes: |>HI, | |> 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 | |>what does? I'm under Ultrix 2.2. I'm doing it by hand, but I'd like to |>be able to do wild card renames, ala DOS. This seems a popular simple question. We had it last year (with its endless discussions, of which I'm guilty too 8-). Any chance that this one is added to the 'list of simple questions & answers', Chris? |Unlike DOS file extensions, the '.' is just another character to unix. |How about: (using /bin/sh) | |for i in *.flip |do |mv $i `sed -e 's/flip$/flop'` |done You probably meant here: mv $i `echo $i|sed -e 's/flip$/flop/'` As it stands, the sed command has no input (well, not what you expect it to have), and the sed expression contains a syntax error. Suggestion: move the sed command to the for command, so that you can do all substitutions all at once: for i in `echo *.flip|sed 's/\.flip / /g;s/\.flip$//'` do mv $i.flip $i.flop done Or, without a loop: apply 'mv %1.flip %1.flop' `echo *.flip|sed 's/\.flip / /g;s/\.flip$//'` (Apply(1) is probably BSD-only). Or: apply 'mv %1.flip %1.flop' `ls *.flip|sed 's/\.flip$//'` Or: (etc, etc, ... ) Leo.