[comp.unix.questions] Stupid ?: directing options in pipe

brad@SSD.CSD.HARRIS.COM (Brad Appleton) (05/02/90)

Mark Routbort writes:
>How can one/can one redirect options to specific parts of a pipe?
>So that something like:  alias ls 'ls | more' will work by sending
>options + filenames to ls and not more?

Since this looks like a C-Shell question (and someone else already gave
a sh/ksh solution) I'll give a C-Shell answer. The following should do
the trick:

  alias ls 'ls \!* | more'

Remember that aliases work somewhat like simple text replacement so
without the '\!*' any arguments given to the ls alias will be placed
after the definition of the alias, on the command line.

In other words, if I have : alias ls 'ls | more'
then typing: ls -A
is (without the alias) equivalent to typing: ls | more -A

If I have the alias: alias ls 'ls \!* | more'
then any arguments to the ls alias are put in place of the '\!*' so
that typing: ls -A
is (without the alias) equivalent to typing: ls -A | more

If you really do want to send options to a different part of the pipe
(which I would discourage given your example) then you should read up
on using parentheses and/or curly braces ( "()"and "{}" ) in your shell.

Hope this helps!
-=-=-=-=-=-=-=-=-=-=-= "And miles to go before I sleep." =-=-=-=-=-=-=-=-=-=-=-
 Brad Appleton         Harris Computer Systems         brad@ssd.csd.harris.com
 (305) 973-5360        Fort Lauderdale, FL USA        {uunet,novavax}!hcx1!brad
-=-=-=-=-=-=-=-=-=-= Disclaimer: I said it, not my company! -=-=-=-=-=-=-=-=-=-