Thursday, May 16, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  156] [ 0]  / answers: 1 / hits: 119179  / 3 Years ago, wed, august 25, 2021, 2:14:34

I am at the path:



/myuser/downloads/


And I create a sub folder:



/myuser/downloads/new


Now I want to move all files and folders/sub-folders in the downloads folder to the sub-folder.



how can I do this?



I tried:



mv -R *.* new/


But move doesn't take the -R switch it seems.


More From » files

 Answers
4

The command



mv !(new) new


should do the trick. If it doesn't work, run shopt -s extglob first.



To also move hidden files/directories (that beginning with a dot), run also shopt -s dotglob first.

So, to sum up:



shopt -s extglob dotglob
mv !(new) new
shopt -u dotglob


(it is always better to unset dotglob to avoid bad surprises).


[#41203] Thursday, August 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fishutt

Total Points: 391
Total Questions: 137
Total Answers: 106

Location: Mexico
Member since Tue, Aug 11, 2020
4 Years ago
;