Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
$ 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)?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

bash:

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

Also bash, and sh (afaik):

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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