R
R
rgzrgz2021-12-15 22:05:13
linux
rgzrgz, 2021-12-15 22:05:13

How to create a file deletion script in linux?

Greetings.
There are a lot of filenames that need to be removed. Search one by one and delete via FileZilla Client is not an option.

Title examples:

sites/default/files/inline/images/tradesanta_ceny.png
sites/default/files/inline/images/zb_exchange_image1_2.png
sites/default/files/inline/images/zb_exchange_image_1.png


Question: how can I make a script that will delete a list of files from the server?
Which command to substitute at the beginning or end of the line?

debian 10 system.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Karabanov, 2021-12-15
@karabanov

find sites/default/files/inline/images/ -type f -iname "*.png" -delete

D
Damian Lewis, 2021-12-15
@DamianLewis

Removing all png
rm -rfv sites/default/files/inline/images/*.png
Removing by mask indicating part of the file name

find sites/default/files/inline/images/ -name '*zb_exchange*' -delete;

All files in the names of which have the word zb_exchange
will be deleted If all files have different names, then only selective deletion or deletion by extension remains

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question