Stupid ?: directing options in pipe
Brad Appleton
brad at SSD.CSD.HARRIS.COM
Thu May 3 00:15:07 AEST 1990
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 at ssd.csd.harris.com
(305) 973-5360 Fort Lauderdale, FL USA {uunet,novavax}!hcx1!brad
-=-=-=-=-=-=-=-=-=-= Disclaimer: I said it, not my company! -=-=-=-=-=-=-=-=-=-
More information about the Comp.unix.questions
mailing list