M
M
Maxim Isaev2018-11-13 16:53:28
bash
Maxim Isaev, 2018-11-13 16:53:28

How to optimize bash code?

Good afternoon, the task is the following, it is necessary to move files from different directories into one. The problem is that you need to check if there is such a directory or file, and the same check goes for each directory/file. How to optimize? There is one option in my head, to create an array of strings that will contain the names of these files and iterate over these names with a for loop, but the search will be in all directories.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Ratkin, 2018-11-14
@Hanharr

Alternatively, use rsync . You just have to be a little confused in order to merge several paths into one.

I
Ingvar, 2018-11-14
@take

I like the idea of ​​using rsync , especially since it's faster than cp or scp copy. It has many options, including --files-from=FILE (read filenames to copy from FILE)
cheerz!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question