7

I have a directory structure like this

├── UK
│   ├── BuyBand_go_UK.png
│   ├── BuyBand_go_UK.svg
│   ├── BuyBand_K.png
│   ├── BuyBand_K.svg
│   ├── BuyBago_UK.png
│   ├── BuyBago_UK.svg
│   ├── BuyBand_ch_Logo_UK.png
│   └── BuyBand_ch_Logo_UK.svg
└── US
    ├── BuyBand_go_US.png
    ├── BuyBand_go_US.svg
    ├── BuyBand_S.png
    ├── BuyBand_S.svg
    ├── BuyBago_UK.png
    ├── BuyBago_UK.svg
    ├── BuyBand_ch_Logo_US.png
    └── BuyBand_ch_Logo_US.svg

How can I move all files in both UK and US directory in parent directory in one command?

This is what I've tried:

   mv (US|UK)/* .

1 Answer 1

11

Try this from the parent directory:

mv {UK,US}/* .

The {A,B,...} syntax is similar to the (A|B|...) syntax used in regular expressions.

If you have dotfiles (hidden files) in those directories that aren't showing up in your listing, run

mv {UK,US}/{*,.*} .

The * glob will expand to all files and directories except for those starting with dots. The .* glob will expand to all of the dotfiles.

1
  • 3
    Note that {a,b} is not POSIX. For a completely portable solution, mv UK/* US/* . or in this very specific case mv U[KS]/* . instead.
    – tripleee
    Jul 24, 2013 at 5:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .