1

I want to search for every file with the name myslq so I can delete it.

I first used this command: sudo find . -regextype sed -regext "./mysql.
This finds me about 880 entries.
This includes everything in my School folder, that I don't want to find. So I added to the regex, that it won't find the files in this folder

For that I used this command:sudo find . -regextype sed -regex "^((?!School).)mysql$"
Which should at least have about 5 entries or so.

When I run the command with the slightly increased regex, I get a Permission denied.
So I tried running it with the root user which also doesn't work. But with the first command it shows me everything: two commands run in root user

As far as I know, the root user should be able to do anything. At least it should be able to run a find command...

Update: Thanks to @Wiktor Stribiżew I figured out, I just used the find command wrong. The working command would be: find . ! -path '*/School/*' -name '*mysql*'

I still get these two Permission Denied: find: /run/user/1000': Permission denied

BeeTheKay
  • 190
  • 13
  • `find` regex does not allow the use of lookarounds. Please check the [How to exclude a directory in find . command](https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command) thread. – Wiktor Stribiżew Sep 09 '21 at 20:43
  • 2
    Try just `find . ! -path '*/School/*' -name '*.mysql*'`, or, if you mean files with `mysql` extension, remove the trailing asterisk: ``find . ! -path '*/School/*' -name '*.mysql'`` – Wiktor Stribiżew Sep 09 '21 at 20:51

0 Answers0