Simone
Simone

Reputation: 2311

Linux mv with matched file names

I want to move in a specific folder all the files matching a simple pattern but i really don't know how; this is what i tried:

mv *.o obj/*.o

don't laugh at me, i'm not really handy with linux.

p.s i don't know if it's relevant, but the mv is actually inside a makefile

Upvotes: 1

Views: 799

Answers (1)

bdonlan
bdonlan

Reputation: 231203

Just do:

mv *.o obj/

The trailing / is not strictly necessary, but I would recommend it - the effect is to have it error out if obj is not a directory (or does not exist) and there is only one .o file; otherwise, it would rename that one .o file to obj, possibly overwriting the pre-existing obj.

Upvotes: 4

Related Questions