Mailinglist Archive: opensuse (3666 mails)

< Previous Next >
Re: [SLE] Command-line puzzle
  • From: Anders Johansson <andjoh@xxxxxxxxxx>
  • Date: Fri, 11 Mar 2005 00:45:09 +0100
  • Message-id: <200503110045.10179.andjoh@xxxxxxxxxx>
On Friday 11 March 2005 00:31, Paul W. Abrahams wrote:
> Here's a little command-line puzzle. Suppose you want to move all files
> from directory A to directory B. You might think that
>
> mv A/* B
>
> would do it. But no -- that doesn't move the dotfiles. So how about
>
> mv A/* A/.* B
>
> No -- that tries to move "." and "..". So how about
> mv A/* A/.?* B
>
> That still tries to move "..", but not ".". Finally, how about
>
> mv A/* A/.[^.]* B
>
> That actually does it, I think -- but it's very inelegant. Does anyone
> have an elegant solution (that works for other commands also)?

shopt -s dotglob
mv A/* B/

Have a look at "man bash" for a description of shopt, dotglob and the other
possibilities available

< Previous Next >
Follow Ups
References