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

7

bash:

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

Also bash, and sh (afaik):

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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