Answer the question
In order to leave comments, you need to log in
How to write a bash script that would only move certain files?
There are a large number of files whose names look like this: 01xxx.vvv 02xxx.vvv ... 999xxx.vvv. With some of the files you need to perform certain actions. There is an array of numbers corresponding to the numbers of the required files. Is it possible to write a bash script that would take only the necessary files (the names of which have numbers from the array) and move them to a folder?
I became attached to the bowl only because I would like to learn how to write in it.
Answer the question
In order to leave comments, you need to log in
ls <from>| grep <regexp>| xargs mv <to>
Compose a regular expression here and substitute in place of <regex>
.
And even better through xargs - it is many times faster and with the preservation of the directory structure
find . -regex ".*\.\(jpg\|jpeg\|gif\|png\|JPG\|JPEG\|GIF\|PNG\)" -print0 | xargs -0 cp --parents --target-directory
./tmp/backup
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question