"mv" all the stuffs excluding sth 
                                                    
                        
                    
                    
  
                    
                    After some experiments, my test-project directory end up in a mess as below:
➜  test-projects git:(daily) ✗ ll
total 88
drwxr-xr-x  18 administrator  staff   576B Sep  9 13:07 R2
drwxr-xr-x  11 administrator  staff   352B Sep 16 10:18 bare-repo-experiments
drwxr-xr-x   9 administrator  staff   288B Sep  6 10:55 central-repo.git
-rw-r--r--   1 administrator  staff    12K Sep  9 13:05 file.bundle
drwxr-xr-x  16 administrator  staff   512B Sep  1 15:04 johns-repo
drwxr-xr-x  18 administrator  staff   576B Sep  3 19:59 marys-repo
drwxr-xr-x  16 administrator  staff   512B Sep  1 10:54 marys-repo-bak
drwxr-xr-x  20 administrator  staff   640B Sep 16 07:31 my-git-repo
drwxr-xr-x  15 administrator  staff   480B Sep  1 11:35 my-git-repo-bak
drwxr-xr-x  16 administrator  staff   512B Sep  6 10:55 my-website
-rw-r--r--   1 administrator  staff    30K Sep  6 10:55 my-website.tar
drwxr-xr-x  19 administrator  staff   608B Sep 12 11:21 repo
drwxr-xr-x  11 administrator  staff   352B Sep 12 21:05 repo.git
drwxr-xr-x  20 administrator  staff   640B Sep 12 21:31 repo2
drwxr-xr-x  16 administrator  staff   512B Sep 12 11:21 repo_m.git
drwxr-xr-x  11 administrator  staff   352B Sep 12 21:06 repo_mi.git
Now I want to have a clean directory but keep all the stuffs. So I want to move all the stuffs into a new subdirectory named first-round. How to do it?
First, I create a directory.
mkdir first-round
Now we can use mv source … directory to accomplish this task, but typing all the stuffs is overly burdensome. Could I move all the stuffs to a specific directory excluding itself?
Yes. The answer is the ‘^’ Glob pattern.
In zsh, we need append this line to ~/.zshrc:
setopt extended_glob
In bash, we need append this line to ~/.bashrc:
shopt -s extglob
Then restart the terminal, run
mkdir first-round && mv ^first-round first-round
The directory is clean now:
➜  test-projects git:(daily) ✗ ll
total 0
drwxr-xr-x  18 administrator  staff   576B Sep 16 13:33 first-round
                        
                        本作品采用《CC 协议》,转载必须注明作者和本文链接
          
          
          
                关于 LearnKu