Sponsored By

Sign in to follow this  
shanenin

Make An Alias For Whereis

Recommended Posts

I notice the whereis command does not use your $PATH variable. In particular it did not find the location of kate. So I decided to try and write an alisas that uses your $PATH variable. this code works

[email protected] ~ $ whereis -B {/usr,/usr/bin,/usr/kde/3.4/bin} -f kate
kate: /usr/kde/3.4/bin/kate

I would think this would also work, but it does not

[email protected] ~ $ whereis -B {`echo $PATH | tr ":" ","`} -f kate
kate:

I would think the above code would expand to this, which does work

[email protected] ~ $ whereis -B {/bin,/usr/bin,/usr/local/bin,/usr/qt/3/bin,/usr/kde/3.4/bin,/usr/kde/3.3/bin} -f kate
kate: /usr/kde/3.4/bin/kate /usr/kde/3.3/bin/kate

Edited by shanenin

Share this post


Link to post
Share on other sites

I found the reason why my method using command substitution and braces does not work. normally items in braces seperated by commas expand with spaces(like I needed)

[email protected] ~ $ echo {dfg,jjk}
dfg jjk

but when I use command substitution in braces it does not behave the same way. I wonder if the maintainers of bash left out being able to use command substituion in braces for a specific reason?

[email protected] ~ $ echo {`echo dfg,ghh`}
dfg,ghh

this code works

whereis -B $(echo $PATH | tr ":" " ") -f kate

Edited by shanenin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this