Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find files not equal to pattern [closed]

Tags:

find

macos

I want to find all files/dirs that are not equal to .git*, so I tried the following commands, but it has the opposite effect (it prints the paths that contain .git).

$ find . ! -name "*.git"
$ find . ! -name ".*.git"
$ find . ! -name "*.git*"
$ find . ! -regex "*.git"
$ find . ! \( -name "*.git*" \)

I also tried the above commands with a \! escape, as in find . \! -name "*.git".

Q: What's the correct syntax for find "not equal to"?

like image 541
tony19 Avatar asked Mar 22 '12 05:03

tony19


People also ask

How do you find files that do not contain a string?

When searching for certain file types that does not contain certain text or strings, you can use this command: >> find /home/example -iname "*. txt" -exec grep -Li "mystring" {} \+ This will list all text files that do NOT contain the term "mystring".

How do I find a specific file pattern in Linux?

The grep command can search for a string in groups of files. When it finds a pattern that matches in more than one file, it prints the name of the file, followed by a colon, then the line matching the pattern.

Which command is used to print those lines of the file which don't contain the string or pattern?

You can add the -l option to print just the file name; but this still prints the names of any file which contains any line which does not contain the pattern.

What is find in bash?

The Bash find Command 101The find command allows you to define those criteria to narrow down the exact file(s) you'd like to find. The find command finds or searches also for symbolic links (symlink). A symbolic link is a Linux shortcut file that points to another file or a folder on your computer.


1 Answers

Aha! I found it here:

$ find . ! -path "*.git*"
like image 121
tony19 Avatar answered Oct 15 '22 07:10

tony19