$ 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)?

link|improve this question

64% accept rate
feedback

2 Answers

up vote 6 down vote accepted

bash:

shopt -s extglob
mkdir backup && mv !(backup) backup
link|improve this answer
feedback

Also bash, and sh (afaik):

$ mkdir .backup && mv * .backup/ && mv .backup backup
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.