Reputation: 6157
I would like to replace all contents of a file that match a given regex to their lowercase equivalent. Like:
grep -o '[^ ]*[A-Z][^ ]*.png' file-21-05-2013.sql* | awk '{print tolower($0)}'
The line above finds all strings in the given file that have at least one uppercase character and prints the lowercase equivalent.
I would like to replace the output of the grep command with the output of the whole command above
Does that make sense?
Upvotes: 2
Views: 2885
Reputation: 2253
sed -nr '/^.*\b(\w*[A-Z]\w*\.png).*$/{s//\1/;s/.*/\L\0/;p}' file
Upvotes: 1
Reputation: 386
If you are using a GNU system then GNU sed has the following extension:
\L
Turn the replacement to lowercase until a \U or \E is found,
The following command should do what you need:
sed "s/\([^ ]*[A-Z][^ ]*.png\)/\L\1/g" file-21-05-2013.sql*
Upvotes: 2