Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
I am trying to use find to search for more than one pattern at a time. I want to be able to pass it as and arguemnt but cant find the proper syntax if there is a way to do it.
for example can it exclude .bkf and .$$$ somehow.
I know it can find /* \! -name *.bkf but can I pass a string argument and exclude both or even more somehow?
thanks, i will do some reading on that. i am redirecting the stout of find to a list that is read by tar. i think i need to keep my end of line null character intact for tar, not entirely sure. please keep the ideas comming. ideally i could do something with find such as find /mnt/public -mtime 8 \! -name [arg1,arg2] > tarlist but i do not know how if it is even possible.
this will filter out all results that contain .bkf and .$$$
and if you want to make sure it only does it to those results that actually end in those characters, then use ".bkf$" hmmm... not sure how you'd do it with the ones with $ in them though... perhaps ".$$$/$" ? but don't quote me hehe or perhaps '.\$\$\$$' ?
Distribution: Gentoo 2004.2, Slackware 10, Windows XP, Windows 2003 Server
Posts: 348
Rep:
cd /
ls -R > file.txt
grep [pattern] file.txt
kind of crude way, but you could then make a little bash script out of this and instantly re-search over and over quickly. Then delete the file at the end.
Originally posted by eccles23 locate blah | grep -v '.bkf' | grep -v '.$$$'
this will filter out all results that contain .bkf and .$$$
and if you want to make sure it only does it to those results that actually end in those characters, then use ".bkf$" hmmm... not sure how you'd do it with the ones with $ in them though... perhaps ".$$$/$" ? but don't quote me hehe or perhaps '.\$\$\$$' ?
The latter match for $$$ is correct: '.\$\$\$' will match any character followed by three dollar signs. If you want to only match a single period followed by three dollar signs, include a backslash before the period: '\.\$\$\$'
A shorter way to do this is to use egrep. Suppose I want a list files in the current directory excluding '.bkf' and '.$$$' files:
Code:
ls -1 | egrep -v '(\.bkf$|\.\$\$\$$)'
Note: I am only excluding files that end in '.bkf' or '.$$$'. If that pattern occurs elsewhere in the file name, it will not be excluded.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.