simple question about mv

VLD/VMB moss at BRL.MIL
Tue Jan 31 01:52:39 AEST 1989


Guy Harris writes:
>>Well, this should work under a Bourne shell:
>>$ for i in *.flip
>>> do   mv $i `basename $i .flip` .flop
> ...
>
>Assuming, of course, that all the files are in the current directory,
>since "basename" will not only strip off the ".flip", but will also
>strip off all the directories leading up to the name (i.e., it will turn
>"/usr/src/nemo/cigar.flip" into "cigar", not into
>"/usr/src/nemo/cigar").
Well, first off, I made a typo, though I really did test this out first,
alas I typed it wrong in the note, it should be:

	mv $i `basename $i .flip`.flop    # note, no space after 2nd `

Secondly, although Guy is correct that this does not work in general, it
*does* work as a solution to the original question; how to do:

	mv *.flip *.flop

I actually used 'sed' first which is more general, but thought that this
was easier for the novice to understand.
-moss



More information about the Comp.unix.questions mailing list