E
E
Eugene2019-03-11 10:17:38
linux
Eugene, 2019-03-11 10:17:38

Find filenames based on month. How?

There are the following files:
01 /01/
2018.7z 11/30/2018.7z 02/02/
2018.7z 04/30/
2018.7z

I want to find all files, excluding those that belong to the last days of the month. These include files 2 and 4 in the list (there are 30 days a year in both months.)
This is how it searches separately for everything except November:
find /mnt/zd-backup ! -name "30.11*"
01.01.2018.7z
02.02.2018.7z
04.30.2018.7z

and so, everything except April:
find /mnt/zd-backup ! -name "30.04*"
01 /01/2018.7z 11/
30 /2018.7z 02/02/
2018.7z

But how do I combine such a search into one line? After all, there are 4 months with 30 days. in a year.
I tried like this, but it didn't work:
find /mnt/zd-backup ! -name "30.(04|11)*"

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nick Sdk, 2019-03-11
@lidacriss

find /mnt/zd-backup -regextype posix-extended -regex '0\d\.\d+\.\d+\.7z'

V
Victor Taran, 2019-03-11
@shambler81

1 option | grep -v "шаблон " | grep -v "шаблон2"
2. option

find /mnt/zd-backup -type f -regex "30\.\(04\|11\)"
- who will screen special characters for you?

D
Dmitry, 2019-03-11
@q2digger

try

find /mnt/zd-backup ! \( -name "30.04" -o -name "30.11"\)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question