Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 2
    Please edit your question and add a reference where you found the claim that the while loop and read are tremendously slow when reading from a file or a pipe Commented Feb 25, 2020 at 15:06
  • Thanks for your recomendation @Bodo. Commented Feb 25, 2020 at 15:27
  • 1
    If you read the referenced answers in detail you can see bad examples that read input line by line and call programs (e.g. cut) to process a single line instead of passing the whole file to the program. Or a manipulation of the input data implemented in shell script code instead of using specialized programs. In your case you have to run cp for every combination of source and destination file name, so I don't see anything wrong with your loop. Please specify if you want to have the same time stamp for all destination files or individual time stamps when copying every single file started. Commented Feb 25, 2020 at 15:45
  • Thanks to your observation @Bodo I made just the clarification that the date and time should be for each file that should be copied. Regarding your performance comment, I greatly appreciate your criteria and I will do the corresponding tests to analyze the time it takes for the process with the code proposed by AdminBee. Commented Feb 25, 2020 at 16:14
  • 1
    I would think that the time spent copying 3 million files will dwarf the time spent by the shell to read a text file. Are you optimizing prematurely? Commented Feb 25, 2020 at 17:54