첫문자를 대문자로

lkjt의 이미지

쉘로 always there for you를 Always There For You로 바꾸려면 어떻게 해야 하나요?

토끼아빠의 이미지

$str = "always there for you";
$str = ucwords($str);
echo $str;

결과
Always There For You

좋은 하루 되세요!!

좋은 하루 되세요!!

lkjt의 이미지

답변 감사드립니다..

하지만 쉘로 할 수 있는 방법은 없을까요?

lifthrasiir의 이미지

echo always there for you | awk 'BEGIN{RS=" "} {printf toupper(substr($1,1,1)) substr($1,2) " "}'

정도면 될까요? 사실 굳이 셸을 쓸 이유는 없습니다만.

cinsk의 이미지

$ echo "always there for you" | sed 's/\<\([a-z]\)/\U\1/g'
Always There For You
$ _

--
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://www.cinsk.org/cfaqs/

pung96의 이미지

 echo always there for you | perl -pe's/(\w+)/ucfirst$1/eg'


echo always there for you | perl -pe's/(\w+)/\u$1/g'

lkjt의 이미지

와~ 답변 감사드립니다~!