A
A
Alexer052021-06-02 11:59:26
linux
Alexer05, 2021-06-02 11:59:26

How to use regular expressions in Linux console loop?

There is a file containing a list of pictures

/path/image_1.jpg
/path/image_2.jpg


How to use regular expressions in this situation in the console to get a file name from a string to save in another folder? Or is there an easier way to save pictures in a new folder?

for var in $(cat ./images_file)
    do // сохранить картинки в папке "new_path/"
done

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Yuriev, 2021-06-02
@Alexer05

move:
mv /path/image_1.jpg /new_path/
or copy:
cp /path/image_1.jpg /new_path/
magic

X
xotkot, 2021-06-02
@xotkot

Or is there an easier way to save pictures in a new folder?

cp $(cat images_file) --target-directory="new_path/"

E
Eugene TI, 2021-06-03
@justhabrauser

If the key here is "get a name from a string", then man basename.
If the key is "copy", then they have already answered.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question