bwildasi@silver.bacs.indiana.edu (Ben Wildasin) (11/13/89)
Another question about the alias command: I would like to modify the rm command so that it first deletes the file, and then copies it to my nfs directory. In other words, I would like to know how I can create an alias that can be passed arguments. Thanks for the information. ************************************************************************** Ben Wildasin bwildasi@silver.bacs.indiana.edu **************************************************************************
jik@athena.mit.edu (Jonathan I. Kamens) (11/13/89)
In article <29537@iuvax.cs.indiana.edu> bwildasi@silver.bacs.indiana.edu (Ben Wildasin) writes: >I would like to modify the rm command so that it first deletes the file, and >then copies it to my nfs directory. In other words, I would like to know >how I can create an alias that can be passed arguments. RTFM. You can use history substitution in an alias. From the csh(1) man page: Note that the mechanism allows aliases to introduce parser metasyntax. Thus we can `alias print 'pr \!* | lpr'' to make a command which pr's its arguments to the line printer. See the man page to find out how to do other, more specific substitutions. Also, I fail to see how an alias is first going to delete a file, and *then* going to copy it to your NFS directory. Finally, your second sentence (about arguments to aliases) does not follow directly from the first, and isn't really a restatement "in other words" of the first question. The two are related tenuously at best.... Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710
brnstnd@stealth.acf.nyu.edu (Dan Bernstein) (11/14/89)
In article <15845@bloom-beacon.MIT.EDU> jik@athena.mit.edu (Jonathan I. Kamens) writes: > Also, I fail to see how an alias is first going to delete a file, > and *then* going to copy it to your NFS directory. Open the file, unlink the file, cat the file to the new link, change the modes of the new link. Even csh can do it. (grin) ---Dan
steinbac@hpl-opus.HP.COM (Gunter Steinbach) (11/14/89)
> / hpl-opus:comp.unix.questions / bwildasi@silver.bacs.indiana.edu (Ben > Wildasin) / 1:03 pm Nov 12, 1989 / > Another question about the alias command: > I would like to modify the rm command so that it first deletes the file, and > then copies it to my nfs directory. In other words, I would like to know > how I can create an alias that can be passed arguments. In ksh, you have to use a "function" instead of an alias if you want to pass arguments to it. RTFM for details. Guenter Steinbach | hplabs!gunter_steinbach | gunter_steinbach@hplabs.hp.com
dg@lakart.UUCP (David Goodenough) (11/18/89)
steinbac@hpl-opus.HP.COM (Gunter Steinbach) sez: >> / hpl-opus:comp.unix.questions / bwildasi@silver.bacs.indiana.edu (Ben >> Wildasin) / 1:03 pm Nov 12, 1989 / > >> Another question about the alias command: > >> I would like to modify the rm command so that it first deletes the file, and >> then copies it to my nfs directory. In other words, I would like to know >> how I can create an alias that can be passed arguments. > > In ksh, you have to use a "function" instead of an alias if you want to > pass arguments to it. RTFM for details. Of course csh does not have functions. So you do things like the following: alias es 'vi +/\!:1/ `grep -l -e \!* *.[chs]`' which edits all C sources, headers and assembler sources that contain a given string: es readDirectory does a bit like a: vi -t readDirectory but as well as finding the declaration of readDirectory, it finds all USES of it. ANYWAY, the \!:n gives you the n'th argument, and \!* gives you all arguments. -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+