osx - Why these simple shell commands fail when used in sed's replacement part -
while trying find answer of this sed question came strange behavior couldn't understand.
let's have file called data
$> cat data foo.png abcd.png bar.png baz.png
the task use sed in line replace lines uppercase ascii characters lowercase. output should be:
$> cat data foo.png abcd.png bar.png baz.png
the solution should work on non-gnu sed sed on mac
i attempted embedded awk sed's replacement part:
sed -e 's/[^ ]*[a-z][^ ]*.png/'$(echo \&|awk '{printf("<%s>[%s]",$0, tolower($0))}')'/' data
strangely outputs this:
foo.png <abcd.png>[abcd.png] bar.png <baz.png>[baz.png]
as can see sed picking right lines uppercase alphabets, , that's reaching awk tolower()
function of awk failing , producing same text input.
can shell expert please explain weird behavior.
sed 'y/abcdefghijklmnopqrsyuvwxyz/abcdefghijklmnopqrstuvwxyz/'
Comments
Post a Comment