I would like to know how can I move all files from folder-A to folder-A's sub-folder except .html file with a command line.
Suppose I am in dist folder and there are 50 files and 5 folders. Now I would like to move all 50 files and 4 folders to one of the subfolder inside dist folder, without having to write all the files name.
Current directory:
$ ls -F
1 12 15 18 20 23 26 29 31 34 37 4 42 45 48 50 8 b.html foldera/ folderd/
10 13 16 19 21 24 27 3 32 35 38 40 43 46 49 6 9 c.html folderb/ foldere/
11 14 17 2 22 25 28 30 33 36 39 41 44 47 5 7 a.html d.html folderc/ moveHere/
Temporary enable shell extglob and disable history substitution:
$ shopt -s extglob; set +H
To move everything to a directory named "moveHere" excluding html files:
$ mv !(*.html|moveHere) moveHere/
Current directory after moving files:
$ ls
a.html b.html c.html d.html moveHere
Check new dir:
$ ls moveHere/
1 12 15 18 20 23 26 29 31 34 37 4 42 45 48 50 8 folderb foldere
10 13 16 19 21 24 27 3 32 35 38 40 43 46 49 6 9 folderc
11 14 17 2 22 25 28 30 33 36 39 41 44 47 5 7 foldera folderd
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments