cdash@boulder.Colorado.EDU (Charles Shub) (04/12/89)
i want an alias (4.3bsd on a microvax, c shell) that will strip a colon (:) out of the middle of an argument i.e. 4:15 becomes 415. That's easy to do with echo piped through sed. what is hard is that i want to use the result as an argument to expr(1) and capture the output of expr. I'm having trouble with escape sequences. The colon is, unfortunately, optional, or i could use the "s" modification of the c shell. Any words of wisdom: desired version mycommand `expr <nocolon> - 5` other args charlie shub cdash@boulder.Colorado.EDU -or- ..!{ncar|nbires}!boulder!cdash or even cdash@colospgs (BITNET)
chris@mimsy.UUCP (Chris Torek) (04/12/89)
In article <8077@boulder.Colorado.EDU> cdash@boulder.Colorado.EDU (Charles Shub) writes: >desired version > mycommand `expr <nocolon> - 5` other args This is easy in sh, harder in csh; in csh it must be done in two steps. What you want is echo $1 | sed s/:// spliced in for <nocolon>; the natural way to express this would be expr `echo $1 | sed s/://` - 5 and so the natural way to express the whole thing would be mycommand `expr \`echo $1 | sed s/://\` - 5` morestuff This works properly in sh, but not csh. So we have to resort to shell variables: set tmp=`echo $1 | sed s/://`; mycommand `expr $tmp - 5` morestuff or two levels of alias: alias part1 'expr `echo $1 | sed s/://` - 5' mycommand `part1` morestuff or anything equivalent to this, as long as it does it `one splice at a time'. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris