Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1442  / 1 Year ago, thu, december 15, 2022, 4:47:39

I am new in Linux so here is my very basic question. I have a directory with 41 folders. I need to create a loop so that the process goes into each folder, copy all the files and then paste everything in a specific folder.



Any idea how to approach this? It would be a lot of clicking without a code solution



In the image you can see all the folders I need to access and the output folder where I want to paste everything (zPASTE_EVERYTHING_HERE)



Directory



My path is: /shared/home/data/output



Would like to paste everything in: /shared/home/data/output/zPASTE_EVERYTHING_HERE


More From » 16.04

 Answers
0

Assuming that:




  • The folders to be copied and their files are under /home/gcgm/myfolders

  • The output folder is /tmp/output-folder



If you need to copy all files to another folder, you can do the following:



mkdir /tmp/output-folder
cd /home/gcgm/myfolders
cp */* /tmp/output-folder





The meaning of */* in the this commandcp / target` is:




  • Take all files (the 2nd *) in all directories (the first *) under the current directory.


[#9885] Friday, December 16, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
errettas

Total Points: 160
Total Questions: 118
Total Answers: 91

Location: Laos
Member since Fri, Sep 11, 2020
4 Years ago
;