simple question about mv

Leo de Wit leo at philmds.UUCP
Sun Jan 29 22:49:28 AEST 1989


In article <7558 at chinet.chi.il.us> les at chinet.chi.il.us (Leslie Mikesell) writes:
|In article <18216 at adm.BRL.MIL> DEG41560 at 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.



More information about the Comp.unix.questions mailing list