How do I list files that don’t match a pattern?
- 0
- Add a Comment
- No Related Post
Dave, I have a straightforward Linux question that’s got me stumped. I have a directory with lots of files that include an underscore, but I want to produce a listing of files that don’t have the underscore, not those that do have it. I can get it with a combination of ls, grep -v and such, but it’s painful and convoluted. Is there a simpler solution?
In an interesting bit of sychronicity, a similar question arose on a mailing list I’m involved with, where the writer wanted to know how to list the opposite of a given pattern.
It turns out that there’s a fairly straightforward solution if you’re willing to delve into the inner workings of the all-powerful find command. If you’ve used find, you probably use it to look for files that are greater than a certain size, have a specific filename pattern, or have a specific permission setting. And yet, find can…
Continue reading at Ask Dave Taylor
