Reputation: 1217
I have a dozens of files that contain the following text:
request {
Request {
input("testing")
}
}
I would like to use sed to capitalize the first letter of any text within input. For example, I want testing to be Testing. I tried the following command to capitalize the beginning of all, but how can I only apply it to input ?
sed -e "s/\b\(.\)/\u\1/g"
Upvotes: 1
Views: 84
Reputation: 26667
How about
sed 's/input("\(.\)/input("\u\1/'
Test
$ echo -e 'request {
Request {
input("testing")
}
}' | sed 's/input("\(.\)/input("\u\1/'
# Outputs
# request {
# Request {
# input("Testing")
# }
#}
What it does?
/input("\(.\)
Matches input("
followed by the first character( in example t
. The character matched by .
is captured in \1
input("\u\1
Replacement string. input("
is replaced with itself. \u\1
converts the character captured in \1
to uppercase.
Upvotes: 1