A
A
AirFlare2021-02-07 16:49:00
bash
AirFlare, 2021-02-07 16:49:00

How to write a .sh script to copy specific files with a specific archive name to a specific directory?

Good day! How to write a .sh script to copy specific files with a specific archive name to a specific directory?
Some details:
We have a ROM folder in which there is a START folder and in it a folder from the unpacked archive (there can be n-th number of folders with certain names) it has files (file_x, file_z, file_r, file_u, file_q, file_h, file_i ). From this / their folder / ok, you need to take file_u, file_z, file_i, file_q and make an archive / s with them, whose / s name is the name of the folder / ok. Then it / they need to be moved to another folder (for example, INPUT).

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
AirFlare, 2021-02-14
@AirFlare

Answer:

cd /way
find . -type f -name "file_u" -o -name "file_z" -o -name "file_i" -o -name "file_q" | zip -r -j `basename "$PWD"` [email protected]

As a result, we will get an archive named way, which will contain files: file_u, file_z, file_i, file_q.

D
Dmitry, 2021-02-07
@q2digger

combination find + tar + mv and add it to cron.

V
Viktor Taran, 2021-02-07
@shambler81

Do I understand correctly that you need to copy certain files but keep the directory tree?
give a couple of examples it was now
show an example of how many there were now

A
alex-du, 2021-03-03
@alex-du

rsync is directly created for this;)
there you can specify a file, where there will be a list of paths or file masks, what to copy (or archive) or specify them directly through command line parameters. and there are a lot of options for all cases of archiving.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question