$ mkdir backup && mv * backup/
mv: cannot move `backup' to a subdirectory of itself, `backup/backup'
有效,但发出警告。退出代码也是 1。
如何正确地做到这一点(但不要太久)?
答案1
重击:
shopt -s extglob
mkdir backup && mv !(backup) backup
答案2
还有 bash 和 sh (据我所知):
$ mkdir .backup && mv * .backup/ && mv .backup backup