2

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'
  • 1
    Why wouldn't you create a function instead? – daisy 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. – Martin Tournoij Mar 7 '13 at 12:07
1

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'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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