csh question (and ksh port maybe)

Stefan Linnemann crissl at rulcvx.LeidenUniv.nl
Tue Nov 13 01:56:32 AEST 1990


In <45969 at sequent.UUCP> calvin at sequent.sequent.com (Calvin Goodrich) writes:

>can any of you unix.gods tell me what :e :h :t :r :q :x :gh :gt :gr
>stand for in csh? i've seen these used before but couldn't figure them out.
>for the rtfm'ers in the crowd: yes, i read the man pages on csh but couldn't
>get an informative answer.

Since I'm not (yet) a god, I will not answer.  Would be a bit pointless,
too, after the excellent answers already sent. :-)

>next question: do these things have an equivalent in ksh? apparently ksh
>doesn't have these little buggers. if they're useful i want to be able to
>use them in my favorite (imho, anyway) shell.

Part of their capabilities are implemented in the ksh(1) as follows:
(From the ksh(1) manual page)

     ${parameter#pattern}
     ${parameter##pattern}
	  If the Shell pattern matches the beginning of	the value
	  of parameter,	then the value of this substitution is
	  the value of the parameter with the matched portion
	  deleted; otherwise the value of this parameter is sub-
	  stituted.  In	the first form the smallest matching pat-
	  tern is deleted and in the second form the largest
	  matching pattern is deleted.

     ${parameter%pattern}
     ${parameter%%pattern}
	  If the Shell pattern matches the end of the value of
	  parameter, then the value of this substitution is the
	  value	of the parameter with the matched part deleted;
	  otherwise substitute the value of parameter.	In the
	  first	form the smallest matching pattern is deleted and
	  in the second	form the largest matching pattern is
	  deleted.  In the above, word is not evaluated	unless it
	  is to	be used	as the substituted string, so that, in
	  the following	example, pwd is	executed only if d is not
	  set or is null:
	  echo ${d:-$(pwd)}

>first person to give me a good answer to both questions gets a free cup of
>coffee at my company's cafeteria.  :]

With the airline ticket attached, this would be an even more expensive
cup of coffee, than for the guy from Illenois. :-)

>thanx guys,

>calvin.

You're welcome.
Stefan.

+---------                                                  ---------+
| Stefan M. Linnemann, a.k.a. crissl at rulcvx.LeidenUniv.nl            |
|                                                                    |
  Life is like the odd bit of string: it should be long enough to do  
  Something Extremely Useful with it, but for all of the really neat  
| things we think of, it's just too short.                           |
| -- Me, 1990, as far as I know; correct me if I'm wrong.            |
+---------                                                  ---------+



More information about the Comp.unix.shell mailing list