Sign up ×
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.

How can I convert the first character of each word in the line after gr-description: to uppercase?

For example :

$ cat /tmp/test1

Output should be


I tried the command below command but I am unable to merge

sed -n '/gr-description:/{n;p;}' grp1 | sed 's/\<./\u&/g'
share|improve this question

1 Answer 1

You appear to be using GNU sed or another version with the \u extension, so you can do this:

sed -e '/gr-description/{n;s/\b./\u&/g;}' < test1

This matches lines containing gr-description, and then runs everything in the {} at that point. n goes to the next line, printing the one we just matched, and then the s command replaces all characters that follow a word boundary (\b or \<) with their upper-cased version (\u&).

This does it all in one go, without piping one sed into another, which wouldn't do what you wanted - you were only getting the one line out, rather than editing the stream as you go.

share|improve this answer
Thanks Terdon. Thank you very much Michael for the solution. – Daya Aug 8 '14 at 9:09

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.