Thanks again for all the replies. I have a further question on this.
Is doing "mv *" considered "bad coding"? In general, no matter which language I do, I try to avoid any side-effect. It reduces readability in the code. Hard to debug when you have pages after pages of code that consists of a lot of "side effects". I much prefer "mv a c" "mv b c" if I want to move directory a and b into c. Am I old school or is this not applicable in shell scripting? -v On Tue, Oct 3, 2017 at 9:39 AM, Pete Lancashire <p...@petelancashire.com> wrote: > Use to be a good 'test' for a Comp Sci class. > > Before the class > > touch a b c > > mkdir d > > In the class > > mv * > > > > On Tue, Oct 3, 2017 at 9:25 AM, VY <vyau5...@gmail.com> wrote: > > > Thanks for all the replies. I completely forgotten about "*" being > > interpreted by the shell. > > That makes sense now... > > > > thanks again! > > > > > > On Tue, Oct 3, 2017 at 9:16 AM, John Meissen <j...@meissen.org> wrote: > > > > > The 'mv' command takes the last argument as the destination. The shell > > will > > > expand the wildcard into a list before calling 'mv' (or performing it, > > as I > > > think it's actually built-in), so in your example > > > mv * > > > is equivalent to > > > mv a b c > > > > > > > Dear All > > > > > > > > Yesterday, I was told of this usage of "mv" and I could not figure > out > > > why > > > > it would work. > > > > So I am sending out my question > > > > > > > > Say I am in a directory with 3 sub-directories "a", "b" and "c". > > > > I then type > > > > > > > > bash> mv * > > > > > > > > Directory "a" and "b" would move under "c". > > > > > > > > I re-read the man page for "mv" and nothing says it can do this. And > > it > > > did > > > > say there needs to be a "source and "destination". From this command > > > above, > > > > there isn't that 2-parameter requirement. > > > > > > > > Can anyone explain why this would work? Or is this an undocumented > > > > side-effect > > > > for "mv"? > > > > > > > > thanks > > > > > > > > -v > > > > _______________________________________________ > > > > PLUG mailing list > > > > PLUG@lists.pdxlinux.org > > > > http://lists.pdxlinux.org/mailman/listinfo/plug > > > > > > > > > _______________________________________________ > > > PLUG mailing list > > > PLUG@lists.pdxlinux.org > > > http://lists.pdxlinux.org/mailman/listinfo/plug > > > > > _______________________________________________ > > PLUG mailing list > > PLUG@lists.pdxlinux.org > > http://lists.pdxlinux.org/mailman/listinfo/plug > > > _______________________________________________ > PLUG mailing list > PLUG@lists.pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > _______________________________________________ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug