ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
reports that there is no such directory (although there is)
on the other hand
find -type f -name "t[123]"
works if I make a small modification like
find -type f -name "*t[123]*"
but I am not sure how it will handle the situation when I have filenames with t8 t9 t10 words in it. Namelly "*t[8910]*" will affect files with t1 also
File name matches regular expression pattern. This is a match on
the whole path, not a search. For example, to match a file named
`./fubar3', you can use the regular expression `.*bar.' or
`.*b.*3', but not `f.*r3'. The regular expressions understood by
find are by default Emacs Regular Expressions, but this can be
changed with the -regextype option.
First this means that "/" as delimiters are not needed. To take your first example:
Code:
find -type f -regex '.*t\(1\|2\|3\).*' -exec rm {} \;
Note the .* on both sides, otherwise you're unlikely to match anything. To get rid of the annoying backslashes, don't use Emacs notation (it kind of sucks as a default):
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.