Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
/usr/portage exclude on locate [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
newtonian
Guru
Guru


Joined: 19 Jan 2005
Posts: 465
Location: Hokkaido Japan

PostPosted: Wed Jan 19, 2005 4:25 pm    Post subject: /usr/portage exclude on locate [Solved] Reply with quote

What's a good way to do a locate for a file and exclude all the matches for /usr/portage/

I was hoping that the code below would do the trick:

Code:
locate qmail | grep --exclude='/usr/portage'


but that doesn't work.


Cheers,


Last edited by newtonian on Mon Feb 07, 2005 9:57 pm; edited 2 times in total
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6052
Location: Removed by Neddy

PostPosted: Wed Jan 19, 2005 5:14 pm    Post subject: Reply with quote

Since locate just scans a database rather than you entire system in realtime, you just have to make the database not scan that directory

There is a file in /etc called "updatedb.conf" if you configure it such (see below" when you run "undatedb" (this is run daily in a CRON job) it will make a new slocate database and then it now omits all those directoried

Code:

root@Fluid etc # cat updatedb.conf
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/slocate/files/updatedb.conf,v 1.13 2004/10/04 04:33:31 vapier Exp $

# This file sets environment variables which are used by updatedb

# filesystems which are pruned from updatedb database
PRUNEFS="NFS nfs afs proc smbfs autofs auto iso9660 devfs tmpfs ramfs ncpfs sysfs supermount devpts usbfs cifs nnpfs subfs udf ntfs"
export PRUNEFS
# paths which are pruned from updatedb database
PRUNEPATHS="/tmp /var/tmp /usr/portage /usr/src /var/db /mnt /var/tmp /proc /sys"
export PRUNEPATHS
# netpaths which are added
NETPATHS=""
export NETPATHS

_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
malone
Apprentice
Apprentice


Joined: 19 Feb 2004
Posts: 159
Location: The p-n junction.

PostPosted: Wed Jan 19, 2005 7:16 pm    Post subject: Re: /usr/portage exclude on locate Reply with quote

newtonian wrote:
What's a good way to do a locate for a file and exclude all the matches for /usr/portage/

I was hoping that the code below would do the trick:

Code:
locate qmail | grep --exclude='/usr/portage'


but that doesn't work.


I imagine there's a million ways to do this, but here are a couple simple ones,
Code:
locate qmail | grep -v '/usr/portage'
locate qmail | sed -e 's/.*usr\/portage.*//' | cat -s

I'm sure there's a nice way of making sed strip empty lines, but I don't know it ... I only use sed for simple things.
_________________
malone
Back to top
View user's profile Send private message
newtonian
Guru
Guru


Joined: 19 Jan 2005
Posts: 465
Location: Hokkaido Japan

PostPosted: Thu Jan 20, 2005 12:43 pm    Post subject: Reply with quote

cool-

Code:
locate qmail | grep -v '/usr/portage'


did the trick. I should have combed the man file a fourth time as it clearly says:

Quote:
-v, --invert-match
Invert the sense of matching, to select non-matching lines.


The /etc/updatedb.conf link is also helpful. I'll add portage to it after the grep -v param etched into my brain.


Thanks again,
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum