my question seems to be general, but i can\'t find any answers.
In sed command, how can you replace the substitution pattern by a value returned by a simple bash fun
I'd like to know if there's a way to do this too. However, for this particular problem you don't need it. If you surround the different components of the date with ()
s, you can back reference them with \1
\2
etc and reformat however you want.
For instance, let's reverse 03/04/1973:
echo 03/04/1973 | sed -e 's/\([0-9][0-9]\)\/\([0-9][0-9]\)\/\([0-9][0-9][0-9][0-9]\)/\3\/\2\/\1/g'