Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to create an alias for tcsh. I would like to find a program in ports (FreeBSD ports).

So far I made an alias, which works, but finds only ports which end in *port_name. I would like it to search for *port_name*. Can you tell why my example does not work?

alias najdi 'echo /usr/ports/*/*\!:1* | sed -e "y/ /\n/"'

.

najdi port_name
finds: *port_name
expected: *port_name*

SOLUTION: I switched to this: (it is also case in-sensitive)

alias portfind 'cd /usr/ports && make quicksearch name=\!:1 | grep Path'
share|improve this question
1  
Why wouldn't you create a function instead? –  warl0ck Jan 27 '13 at 14:03
    
I dont know what is function (in this context). After quick search, i found "TIP#1: Overcome lack of functions With a clever use of alias and scripts, lack of 'functions' can be easily overcome." tcsh.org/TipsAndTricks –  Martin Jan 27 '13 at 22:37
    
You may want to look at ports-mgmt/psearch, does the same with more options. –  Carpetsmoker Mar 7 '13 at 12:07
add comment

1 Answer

In tcsh the expansion !:1* is equivalent to !:1-$

To achieve what you want you need to do this:

alias najdi 'echo /usr/ports/*/*\!:1-1* | sed -e "y/ /\n/"'

Personally I prefer to use find instead of shell expansion:

alias najdi 'find /usr/ports -type d -maxdepth 2 -name \*\!:1-1\* -print'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.