2
$ mkdir backup && mv * backup/
mv: cannot move `backup' to a subdirectory of itself, `backup/backup'

Works, but issues a warning. Also exit code is 1.

How to do it properly (but not [much] longer)?

2 Answers 2

7

bash:

shopt -s extglob
mkdir backup && mv !(backup) backup
2

Also bash, and sh (afaik):

$ mkdir .backup && mv * .backup/ && mv .backup backup

You must log in to answer this question.

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