Using GNU sed
, use an address (indicating the target line number) to tell it to apply the substitution to the desired line. For example to apply the substitution to the first line:
sed -r '1s/(\w)(\w*)/\U\1\L\2/g' file
To apply the substitution to the third line:
sed -r '3s/(\w)(\w*)/\U\1\L\2/g' file
To apply the substitution to both the first and third lines:
sed -r -e '1s/(\w)(\w*)/\U\1\L\2/g' -e '3s/(\w)(\w*)/\U\1\L\2/g'
If you don't mind the second line being modified, you can use an address range:
sed -r '1,3s/(\w)(\w*)/\U\1\L\2/g'
EDIT:
As per comments below:
sed -r '/^chapter/I { s/^/# /; s/(\w)(\w*)/\U\1\L\2/g }' file
Results:
# Chapter One
Blah, blah, blah.
# Chapter One-Hundred-Fifty-Three
# Chapter One
Blah, blah, blah.
# Chapter One-Hundred-Fifty-Three