K
K
kizijo2018-07-06 23:46:58
linux
kizijo, 2018-07-06 23:46:58

How to insert a regular expression in the find command?

To search for all files on the server whose modification dates are less than 1 month, I use the following command:

find /home/user -newermt $(date +%Y-%m-%d -d '1 month ago') -type f -print

How to modify this command so that the search results exclude the addresses of files that contain the substring com/trash/? Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2018-07-07
@kizijo

find ... | grep -v 'com/trash/'

S
Saboteur, 2018-07-07
@saboteur_kiev

Why regular season if you just have a mask?
Why this complicated construction, if there is just -mtime?
find /home/user -mtime -30 ! -path"*com/trash/*"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question