[Gllug] Grepping tab-completions

Joel Bernstein joel at fysh.org
Mon Jun 13 09:33:30 UTC 2005


On Mon, Jun 13, 2005 at 10:25:00AM +0100, Tom Schutzer-Weissmann wrote:
> Hi
> 
> I'm trying to remember the command that will let me use KDE io-slaves
> from bash, and I think it starts with 'k' and contains 'exec'. So what
> I'd like to do is pipe the names of all the commands available on my
> path that begin with 'k' through grep, but haven't a clue how.

My first instinct is to iterate around each element in $PATH, glob it
[perform filename expansion], and then look for files beginning with k
as follows:

for dir in $(echo $PATH | tr ':' ' '); do
	echo $dir/* | tr ' ' '\n' | egrep "^$dir/k"
done

or probably rather more efficient:
find $(echo $PATH | tr ':' ' ') -name 'k*'

/joel
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list