passing sed backreference to base64 command
问题 What I am trying to achieve is pass the Base64 encoded value captured in the sed regex to the base64 and have it decoded. But the problem is, even though it seems like the correct value is being passed to the function using backreference, base64 complains that the input is invalid. Following is my script - #!/bin/bash decodeBaseSixtyFour() { echo "$1 is decoded to `echo $1 | base64 -d`" } echo Passing direct value ... echo SGVsbG8gQmFzZTY0Cg== | sed -r "s/(.+)$/$(decodeBaseSixtyFour