Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a builtin way in KornShell to capitalize a word, e.g. korn -> Korn? A Bash 4 example to clarify:

echo "${str^}"

If there is not a bultin way to do this in KornShell, what is the most concise and efficient way to write a function that will do it?

share|improve this question
bash can do this with M-c (typically, Alt-c) at the beginning of the word. No idea about ksh though. –  jw013 Jul 16 '12 at 15:04
@Kazark, better specify whether you want editing or scripting functionality. My understanding was that you want something like str='korn'; echo "${str^}" in bash. But after @jw013's comment I am not so sure. –  manatwork Jul 16 '12 at 15:08
@manatwork Thanks. Done. –  Kazark Jul 16 '12 at 16:06

1 Answer 1

up vote 3 down vote accepted

Here is a pure ksh (ksh93) way:

function cap {
    typeset -u f
    printf "%s%s\n" "$f" "${1:1}"

$ cap korn
share|improve this answer
Not excessively verbose. +1 ...I didn't know the syntax for string slicing, so that is helpful. –  Kazark Jul 16 '12 at 20:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.