Odimegwu David
Odimegwu David

Reputation: 43

A command that I ran that works wrongly in sed

this command does not work in sed, version 4.2.1.

    sed 's/[[:upper:]]/[[:lower:]]/' <file. 

although it does detect the upper case pattern, it does not do the conversion to lower case, rather it converts the captured patterns to [[:lower:]]. any workaround?

Upvotes: 1

Views: 66

Answers (2)

iruvar
iruvar

Reputation: 23364

With sed, you need to capture the upper-case pattern in a group and then substitute with the lowercase version

sed -r 's/([[:upper:]])/\L\1/g' <file

Upvotes: 0

konsolebox
konsolebox

Reputation: 75488

Use tr instead:

tr '[:upper:]' '[:lower:]' file

Upvotes: 2

Related Questions