LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Filter not working (https://www.linuxquestions.org/questions/linux-general-1/filter-not-working-4175611566/)

TBotNik 08-08-2017 11:49 AM

Filter not working
 
All,

I'm running the cmd:
Code:

locate -i notes | grep -i dropbox --exclude-dir=[\*ProJects*\} | grep \.doc > /home/files/notes_dump.txt && gedit /home/files/notes_dump.txt
but always still have the "ProJects" directory showing in the results.

What is not right with my grep statement?

Thanks!

TBNK

TheEzekielProject 08-08-2017 12:12 PM

Code:

--exclude-dir=[\*ProJects*\}
You have different brackets

TBotNik 08-15-2017 10:42 AM

Quote:

Originally Posted by TheEzekielProject (Post 5746073)
Code:

--exclude-dir=[\*ProJects*\}
You have different brackets

TheEzekielProject,

Thanks for the bracket check, but still getting this/these directories in the output:

Code:

/home/files/Dropbox/ProJects/Web/External Projects/
Do I need to use REGEX instead? It seems to work better when the dir you are filtering out is in the middle of the dir string. Am I right?

So what is The Ezekiel Project?

Cheers!

TBNK

TBotNik 08-30-2017 02:00 PM

Can I get some help here?

chrism01 09-04-2017 06:23 PM

I think the problem is that the o/p of 'locate' is effectively a bunch of strings (as opposed to eg grep -r , which is actually reading the dir nodes content ).

Try using 'grep -v' or even 'egrep -v' on the 'locate' o/p.

HTH

ondoho 09-05-2017 12:55 AM

don't use locate for changing, user created content.
also, since you are piping locate's output to grep, i don't think the --exclude-dir option makes any sense there.

please explain what you are trying to achieve, we will help you formulate a better command.

pan64 09-05-2017 02:55 AM

You did not tell us how did you fix that problem in post #2. So how can we go further?

TBotNik 05-03-2020 11:44 AM

Followup
 
All,

Following up on all my open threads, looking to close/solve them all.

Cheers!

TBNK

onebuck 05-04-2020 07:27 AM

Moderator Response
 
Do not bump necro threads unless you have relative content as OP;
Quote:

LQ Rules Do not post if you do not have anything constructive to say in the post.

JJJCR 05-08-2020 01:14 AM

Quote:

/home/files/Dropbox/ProJects/Web/External Projects/
Quote:

--exclude-dir=[\*ProJects*\}
Both are different "ProJects" and "Projects" in the context of case sensitivity.

You can try:

Quote:

grep -i -r dropbox --exclude-dir=[\*Pro?ects*\]


-r = for recursive search

Good luck!

pan64 05-08-2020 02:26 AM

this is completely wrong.
--exlcude-dir has only any effect if you use recursive search (grep -r), not when grepping stdin.
From the other hand grep -v <pattern> may work (as it was already suggested).

Quote:

Originally Posted by TBotNik (Post 6118810)
All,

Following up on all my open threads, looking to close/solve them all.

Yes, I would like to see a follow up from you. If it was still a problem for you, if you have already tried any suggestion posted.

TBotNik 06-08-2020 12:16 PM

All,

As a KDE user, I normally use "KFind" which searches the entire system including any flash drives active, but kfind sometimes blows on install, so not always available.

Both "find" and "locate" are limited to the "/home" directory!

What is needed is a command line equivalent of "kfind" that will search the entire system by default.

I'll try to find the right board to post this one so the OS level gurus will create the right command for this!

If anyone has a bash script that equals "kfind"; I'll go ahead and mark this solved. Please share if you have such a script!

Cheers!

TBNK

scasey 06-08-2020 01:12 PM

Quote:

Originally Posted by TBotNik (Post 6118810)
All,

Following up on all my open threads, looking to close/solve them all.

Cheers!

TBNK

To mark a thread [SOLVED], use the Thread tools at the top of the thread. There is no need to also post.


All times are GMT -5. The time now is 09:02 AM.