Sign in to follow this  

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

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`}

this code works

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

Edited by shanenin

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this