csh question (and ksh port maybe)
Matt Day
mday at iconsys.icon.com
Sat Nov 10 06:32:54 AEST 1990
In article <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.
Here's a little set of examples (note: I use the tcsh; I don't think the
tcsh and the csh behave differently here, but they might):
> set tmp="/usr/tmp/foo.bar.howdy"
> echo $tmp:e # (extension) Returns the text to the right of the last '.'
bar
> echo $tmp:h # (head) Returns the "head" of the path
/usr/tmp
> echo $tmp:t # (tail) Returns the "tail" (or basename) of the path
foo.bar.howdy
> echo $tmp:r # (root) Returns everything except for the last '.' extension
/usr/tmp/foo.bar
The :q and :x modifiers are means of setting the high bit on the variable
contents. :x will set the high bit on all the text in the string except for
spaces and tabs, and :q will set the high bit on everything. I can't see
very many practical uses for this feature.
As for the :gh, :gt, and :gr modifiers, they seem to do weird things on
my copy of tcsh. Perhaps they're broken, perhaps I just don't understand
what their purpose is. In any case, I don't know what they really do.
I think the 'g' means "global" somehow, but I can't tell right off.
Anyway, that ought to get you started. Those modifiers are really handy,
I use them all the time. Saves lots of typing, and in shell scripts, they
save a call to "sed".
>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.
Sorry, I don't know about the ksh.
--
- Matt Day, Sanyo/Icon, mday at iconsys.icon.com || uunet!iconsys!mday
More information about the Comp.unix.shell
mailing list