Linux: Find command with "or"

Linux has a very powerful find command, but it can be daunting to get all the options right. Recently I needed to find all my new .txt and .pl files. To do this you need to be able to say "find all the files that are text OR perl". In Linux find that looks like:

find /dir/path/ -type f \( -name '*.txt' -or -name '*.pl' \) -ctime -7

The spaces after and before the surrounding parenthesis are required or you will get weird error messages. Lots of research and examples borrowed from

Leave A Reply
All content licensed under the Creative Commons License