Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!ichthous.Eng.Sun.COM!mcgrew From: mcgrew@ichthous.Eng.Sun.COM (Darin McGrew) Newsgroups: comp.unix.shell Subject: Re: Building an awk alias in (t)csh Message-ID: <6110@exodus.Eng.Sun.COM> Date: 16 Jan 91 22:30:09 GMT References: <3064@ux.acs.umn.edu> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 24 edh@ux.acs.umn.edu (Eric D. Hendrickson) writes: >I would like to make an alias like this: > >alias where "who | grep \!:1 | awk '{print $6}' -" As you may have already figured out, the $6 gets expanded at the time that the alias command is executed, because it is within the double quotes. You need to protect the $6 from being expanded by the shell when the alias command is executed, and you also need to protect it from being expanded by the shell when the alias itself is being executed. The following works: alias where "who | grep \!:1 | awk" \''{print $6}'\' - because the unescaped single quotes protect the $6 from expansion when the alias command is executed, and the escaped single quotes become part of the alias and protect the $6 from expansion when the alias itself is executed. Darin McGrew "The Beginning will make all things new, mcgrew@Eng.Sun.COM New life belongs to Him. Affiliation stated for He hands us each new moment saying, identification purposes only. 'My child, begin again. My child, begin again.'"