Gentoo Archives: gentoo-user

From: Alex Schuster <wonko@×××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] locate
Date: Fri, 11 May 2007 14:43:25
Message-Id: courier.46447F71.0000413A@zone.wonkology.org
In Reply to: Re: [gentoo-user] locate by Martin S
1 Martin S writes:
2
3 > Anyway I don't have a mouse on that system, so I'll have to use Alan
4 > suggestion.
5
6 You could use a little shell function like this one. Add it to your
7 ~/.bashrc or somewhere like that.
8
9 locatecd()
10 {
11 oldIFS=$IFS
12 IFS=$'\n'
13 results=( $( locate "$1" ) )
14 ret=$?
15 IFS=$oldIFS
16 if (( ret ))
17 then
18 echo "Sorry, '$1' was not found."
19 return $ret
20 fi
21 if (( ${#results[@]} > 1 ))
22 then
23 echo "More than one file found, using the first one."
24 fi
25
26 cd "$( dirname "${results[@]}" )"
27 }
28
29 Alex
30 --
31 gentoo-user@g.o mailing list